Many emulators have this functionality, called netplay. For example Mesen, one of the best NES emulators available:
https://www.mesen.ca/docs/tools.html#netplay
Also RetroArch (which has cores for many systems, including Genesis):
FightCade2 is the most popular. Takes some work to set up, but has a lot of old games. No NES. Plenty of arcade though. There was Kaillera back in the day. I don't know where is stands now.
maybe https://parsec.app
Check out kosmi.io for nes and snes emulators in multiplayer.
I think the easiest way to do this is simply RDP. Have the emulator set up, open up RDP, and have them RDP into the machine. Then when you use the emulator map the player 1/ player 2 keys to whatever. It should work.