Either it's in the console ROM, in which case it's not a problem, or it's in the cartridge ROM, in which case I'd imagine it's just a matter of replacing the raster data with something else.
It's in the game, but the console famously checks that the code for the logo is present, and refuses to run any game which doesn't have the code in place.
It was used as a way to prevent anyone unauthorized making games. If you copy the logo, you have violated trademark and copyright law, and if you don't copy the logo, your game won't run.
If I remember correctly, the ROM gets read once to check, and then again to display. One could use some circuitry to deliver another logo on the second read.
The idea is that by forcing games to include the trademarked Nintendo logo in the game ROM, an unlicensed dev would be guilty of trademark infringement if they used the logo.