As BrunoRB said, you probably will not be able to do what you want by using HTML / Javascript only. But if your .html page is on your server and you have access, you could change it using just javascript, but it would not be the user's browser engine, but through Node.JS, which is the Chrome Engine V8 running in the server.
If you want to change the source code of a page, you basically have two alternatives, or change it on the server, before sending the response to the client (in this case you could use NodeJS), or you change dynamically in the client using Javascript, which is actually not a true change in the source code but only a manipulation of the document in the client.
You could also do something complex, like creating a copy of the .html file in the client's storage using FileAPI with another series of processes that would get more or less the result you expect, but I think that's not quite the what do you want.
link
Finally, the javascript code that you run in the client browser does not have direct access to your files on the server, ie you could not just use it to modify your source code. But there are ways to get this result, modify the source code of a page with javascript, but this involves more technologies than just HTML / Javascript running in the browser.