For newer systems that is not so bad if you have conditionals*.
If you are restricted to more old school cheat styles without such things then that is harder and presumably why they were game genie codes as conditionals are basic programming really and you can edit the game's programming with them.
*this is the if greater/less than, if equal to, if between range... type things later cheat formats. In that case finding the counter for blue spheres is the same as any other cheat finding
https://web.archive.org/web/20080309104350/http://etk.scener.org/?op=tutorial
Easy enough then to either set it to 99 or to 0 depending upon what needs doing.
One emerald to get them all might be harder. If memory serves it does one after the other regardless of level (though maybe not two in the same act) depending upon how many you got before then. That means a counter is more likely but it could still be an inventory.
Anyway that might be getting ahead of things.
There are two ways for the game to store emeralds
1) The game treats it like any other counter (rings, lives, continues, score, timer...) and just adds one for every successful run.
2) Each emerald is its own entry in the "inventory" for the game. This sort of thing is normally reserved for key items in games but there are perks to doing it for something as simple as emeralds.
What I would do is make a savestate before going into a bonus stage. Start the cheat search. Jump into it (preferably from below or with minimal movement). Get the emerald and immediately upon being returned to the level then do a cheat search for anything different. It is only one item though so can be harder to narrow down compared to rings, time, lives and things you can easily manipulate. To that end you might try an alternative route -- chances are the emerald storage is right near the rings, lives, continues, score and whatever else location in memory (it is all user data after all and will need to be saved so better to have it all together). Find where score, rings, lives and whatnot is located and look nearby there after bonus stages.
You can even use the other region cheats here to see what goes -- changing such things between regions is not really the done thing so what works for NTSC-U and PAL will likely also be similar in nature for NTSC-J.
The third route is get all 8 emeralds. When you press the combo to turn into super sonic it will have to check you have enough emeralds to do it and that will also key off the key presses and maybe a ring counter (can't remember if you need a minimum count to start) so you could then do a breakpoint (break on read most likely) for anything touching the ring counter, assuming you did not manage to land on an enemy or spikes after you set the breakpoint then the next thing to touch the ring counter will either be the activation or the ring consumption mechanic.
I don't know what goes for the disassembly of such games either (I know Sonic 1 megadrive has been done but have not looked for the rest and the remakes do their own thing most of the time) but if they are available then they might shine a light on what goes.