You can't get the pistol through normal play—it's a computer-only hack. If you're on PC, open the developer console and type "sv_cheats 1" to turn cheats on (0 turns them off). Then enter "impulse 101," which actually gives you all the Half-Life 2 weapons rather than just the pistol. So there's no way to grab the pistol alone, but this unlocks the full arsenal.