On the MD2, they added audio output pins to the expansion port in addition to the existing audio input pins. This allows them to achieve the same effect with no mixing cable.
The Megadrive has a stereo sound input on the cartridge port too, for a total of 3 stereo sound sources (the YM2612, the MegaCD, the cartridge) plus one mono source (the SN76489 PSG).
As far as I know no original release ever used the cartridge input, but nowadays it is supported by many flashcarts to emulate the MegaCD or to provide CD quality audio tracks (MSU-MD and MD+ romhacks), and it has been used by some recent games.