Can't say how to do it with a gateway, but there are a few threads in the forum that discuss achieving this in different ways. Mine utilizes a few selects, tables, and the php mailfunction to send an SMS to cellnumber@carrier.com,net,whatever.
For example...
sending an email to 1234567890@tmomail.net will result in a SMS being sent to 1234567890 as long as its a valid number with t-mobile.
The carrier forwards the email content to the cell number as an SMS.
My mod is only to send SMS replies. It (still) doesn't append a note to the thread, but, it should give you a good idea of how to start with your own solution.
(http://osticket.com/forums/showthread.php?t=6293&highlight=text+message)