IANAL - There were original boards - someone hacked a galaga board to make it play PacMan.
And "illegal to have" is kinda vague. You are probably infringing on someone's intellectual property and copyrights, but what the penalties and legality of this is has not been determined.
Namco releases PacMan. The PCB doesn't mention copyright one way or another. Theoretically, you could take the board and dump the rom contents off the board and use it with an emulator. Most people think you could download the ROM and play it in an emulator, but this has not been established legally.
Company X releases Galaga on PacMan hardware. This probably infringes on Namco's rights, as I'm sure that Company X didn't obtain permission before modifying the board. I don't think owning the PacMan board entitles you to this ROM. If you own the Company X board, theoretically, you could take the board and dump the rom contents off the board and use it with an emulator. This would infringe on Namco's IP, but not Company B's. Most people think you could download the ROM and play it in an emulator, but this has not been established legally.
Finally, it's not really been established whether (outside of StarRoms) there are any circumstances where you can (or cannot) use the ROM images for any game.