The cheat system in Mame works by monitoring memory locations known to be home to key game information, such as the number of lives left or whatever.
If you want to modify the actual game to display "Tommy XYZ" instead of "Game Over", rather than modifying the emulator, that is doable with a hex editor subject to the checksum restrictions Ray mentioned.
More complicated still is the new Donkey Kong code which implements new levels using the existing sprites.
I personally would like to extend Galaga to include "tripleship" support and a screen saver. That would be a fun project, and it would be super cool to load those roms into my Galaga machine at home.