That's a great question. We've tried using the bit.ly shorten API method in conjunction with an AMPscript HTTPGet function (to make a request to the API) to shorten a URL. This works well, but the problem was that we quickly hit a rate limiting issue where we started receiving a 403 HTTP Status codes back from bit.ly.
It turns out that bit.ly has a monthly rate limit of 5,000 links created and an hourly limit of 1,000 and a 100 in a minute. This is for the free usage edition. We looked into their paid plans and the cost was going to be pretty expensive (~$850 per month), so we ended up building our own API.
So, depending on how many SMS messages you want to send, the bit.ly API could be an option. If bit.ly is an option for you, here's some code that should work:
var @Id, @shortenUrl, @bitlyUrl, @link
set @Id = AttributeValue('Id')
set @link = URLEncode(CloudPagesURL(383,'Id',@Id))
set @bitlyUrl = 'https://api-ssl.bitly.com/v3/shorten?access_token=ACCESS_TOKEN&longUrl='
set @shortenUrl = HTTPGet(Concat(@bitlyUrl,@link,"&format=txt"))
Note that you obtain the ACCESS_TOKEN
from your bit.ly account but it's persistent and doesn't expire, so you don't need to generate a new one each time.