Individual apps may sometimes have their own method for writing superscripts or subscripts. But it's important to remember that this is limited to those apps that have advanced support for paragraphs, line heights, embedded graphics, etc. You'll be limited to working within those apps. You probably won't be able to export the data with subscripts in any meaningful format. For example, you could print or print to PDF, but then it's not really a subscript anymore, it's just a glyph drawn elsewhere with a different size.
What you can do is use official superscript and subscript characters. Use the Character Viewer available from Emojis and Symbols in the menubar. See Use emoji and symbols on Mac - Apple Support
In the Character Viewer, you can search for either "subscript" or "superscript" and it will show you all the characters of that class. You can create favourites for those to easily insert them. Or you could create other types of text replacement commands using those characters, as described here: Replace text and punctuation in documents on Mac - Apple Support
If you use this method, then your characters retain their intrinsic "superscript" and "subscript" attributes. Unicode characters are well supported these days so they should be portable. You can even use them in a web-based editor like this one¹.
¹It might take a couple of tries sometimes