Since the introduction of the new spreadsheet version one can change text attributes inside a single cell (or merged cells) manually like in this example :
(left = raw text, right = formatted text, easier to read)
I don't see any way to achieve that by script... I don't see any issue nor feature request in the issue tracker either.
Is that possible ?
Every method I try to get the text attributes only returns a single value so I'm afraid I just can't do it... but who knows ?
At this time in Google Sheets is not possible to programatically apply formatting to cell content parts.
Please star the following feature request on the Google Apps Scripts issues and feature requests officil site:
Issue 6000: Handle parts of cell content programmatically