You cannot. Shadow was not introduced to the Sonic series until roughly nine years after Sonic the Hedgehog 2 was released.
The original Sonic 2 shipped with Sonic and Tails as the only playable characters, and there is no hidden unlock that changes that. Any claim otherwise is a rumour or a hack.
If you want to play as Shadow in a classic-style game, your options are the later titles that actually feature him, or fan-made ROM hacks built for exactly that purpose.