I've done this! It's super fun! You really need player buy-in for best results, and it helps to know and trust your group. But I've done it two different ways. The first might work best for a "surprise everyone"
Everyone Gets A Note
This is useful for many situations besides this specific question. Pass a note to each player. All but one of the notes will say something like "Don't tell the others this note doesn't say anything." Heck, sometimes ALL the notes would say that. Just to keep 'em guessing. But sometimes one note would say more.
To maintain the level of surprise you're looking for, the notes would have to be pretty subtle. I've done this to start with, but I'll admit I never maintained it all the way through for that one player. "For some reason, you're really curious about Project X." "For some reason, you really want to get your hands on that map Bob found." If you want to provide clues, you can do that in notes to others. But if the master spy is a real master, you probably don't want too many of those.
That said, I think getting the player in on the gag is a better way to go. In the specific instance of replacing a PC, you can give a player a note which reads, "You are now a spy disguised as your PC. Act normal until further notice."
I used this in my pulpy horror game when a PC was replaced by a shifter. Notes began as "There's nothing happening here and you want to go home." Later they were "You have a bad feeling about anyone going near the shed." And finally admitting to the player, "You're the shifter. Convince the others to go home without alerting them, or attack them."
When the player announced he was attacking another PC, it was an awesome moment of "WTF?!?!" Then when the shifter reverted to his natural shape, I took over and told the player "You wake up locked in the shed," it was awesome fun.
Swap Character Sheets
I used this method in a convention game with pre-gen characters, and I've used it with my regular group. Just make a character sheet and when the time is right, swap it out. There are several ways to do this without alerting the group:
- Ask for the sheet and pretend to copy down a note. Hand back a
different sheet. I did this in the convention game four times without
getting caught.
- Swap sheets during a smoke/restroom break.
- Some GMs keep character sheets for Players. That's super easy. In my
group, I gave players cheap folders with their characters which I
collected after sessions. They were used to getting them back with
notes, extra XP, etc. One week I just gave a player a different sheet
entirely.
You don't have to do the sheet swap or note passing at the exact same time as the in-game swap, either. When I did the sheet swap for my group, I did it between weeks, and the new sheet had a note letting the player know the moment during last week's session the switch happened. "Remember last week when you fell into the water and the others hauled you out? Well... it wasn't you they hauled out."
I've used both of these and they work. The note passing method is better for a game where you want players on edge. Always passing notes will put many players on a sort of general alert. This is great in some games where you want them looking over their shoulders.
The swapping method provides a more subtle transition without getting the party on edge, which often makes the reveal that much more satisfying. But it also needs the most buy-in. It's also SUPER fun to do it the spy doesn't have the same skill set as the character he's replacing. Although that won't work well for a long term swap, it's great for a short term swap. "It's an ogre! Bob, fireball!" "Er.... I didn't have a chance to study my books this morning. Sorry."