For the most part, it's a carrier thing. In the US, generally speaking, any SMS traffic has to be from a number you 'own'. For APIs, that would be one or more virtual numbers you purchase.
Outside the US - again, generally speaking - there's more freedom in what you can use. However, different APIs may or may not choose to expose that. For example, with Nexmo you can set the sender ID to whatever you want, with countries / carriers where that's supported.
As to what countries / carriers support a dynamic sender ID, this Nexmo Country FAQ may be helpful (even if you're using a different API).
(Disclaimer: I do some developer evangelism for Nexmo.)