The Cosmos\Icon class does some nasty work and quite a hack. We should work on using OOUI icons to replace these other icons, to fit the MediaWiki conventions.
Ultimately the goal should be that we can just store plain SVG files under resources and load them through ResourceLoader. Currently the icon SVG data is stored in a nested associative array, but that's not very nice to have. See https://www.mediawiki.org/wiki/Manual:ResourceLoaderImageModule.php
Switching to ResourceLoaderImageModule would slightly change behavior as they would have to be applied as a background image via the CSS background-image property.
To ensure we can keep the same behavior (for now), we should keep outputting the SVG files into the HTML DOM. We can parse an SVG string to a DOM tree, and then modify the attributes that way.