Additionally, lemmy-ui has a flag called LEMMY_UI_CUSTOM_HTML_HEADER which I assume allows you to add a JS script to be executed on page load, which you could use to modify the HTML after the fact.
To modify the HTML in a more proper way, you’d have to pull the lemmy-ui project (github.com/LemmyNet/lemmy-ui), make your changes and then build your own docker container with it.