covers how they are encoded and what the payload is once you are there.
If you have the hack already you then encode the locations and changes accordingly. Only small hacks can be done in hardware game genie setups as they are limited to a fairly small number of codes (emulators might as well be infinite on PC, console based emulators might be limited, flash carts vary a lot but at that point you might as well just run a custom ROM).
If you want to make a hack then you get to figure out what you want to edit and how to hardcode it so the ROM sees it. This is as game genie, at least for the NES, has minimal RAM editing options. If you want infinite health you have to figure out a way to either write the health value a lot (say by inserting it into the vblank routine) or edit the instruction that subtracts from health when damaged to be a NOP or plus (jumping in a pit now adds to your life counter), or maybe editing the stats (does anything touch you or matter if you have 255 defence and 9999 health?) or giving yourself infinite potions if you would rather go that way.
You are not limited to the normal sorts of boring cheats that RAM editing ( https://web.archive.org/web/20080309104350/http://etk.scener.org/?op=tutorial
) tends to be restricted to and can do very small ROM hacks (could change a bit of a sprite, something in the audio, maybe some of the game's code to do something rather more radical, and some of what would otherwise be RAM cheats could be more precise -- later systems have all sorts of things like checks to see if a number is within a range, seeing if a button combo is pressed, higher than, lower than, boolean and bitwise operations (as in NOR, OR, XOR, AND, NAND, right shift, right rotate, ceiling, floor, possibly some maths...) and you could do that too which might make cheats more interesting or possible where simple infinite health might say cause you to lose a "must fail" boss fight, or for the end of level screen might not end if the health/time keeps being restored and it is trying to determine the bonus for health/time remaining.
If you mean you want to make a code for an already hacked ROM then hacked ROM or stock ROM 1:1 as came out of the factory... it matters not. Sure the hack could have changed the locations of some things, altered some data or otherwise made it such that codes designed for the original game don't work properly now but that just means you make a new cheat instead. No real difference to trying to make cheats for a PAL game when only NTSC codes exist, or making codes for a v1.3 version of a game when most existing stuff is aimed at v1.1 or something. There are some similarities that you could look for (most code does not change that much between regions or versions or in hacks, just gets shuffled around in memory/ROM a bit so you can possibly find it by looking for similar markers or unique memory/ROM locations) to make life easier in those scenarios, but often I don't bother and will instead just remake the code from scratch having maybe understood a bit about the memory design in the other region from the other codes.