There are a number of spells and monsters in various fantasy and sci-fi RPGs that can significantly influence a PC's behavior, take control of a PC altogether, or even replace a PC without the knowledge of the rest of the group (e.g., the doppelganger from Dungeons and Dragons). The way I have usually seen this handled is for the DM to simply inform the player that they have lost agency as a character and take control of the PC. This method seems heavy-handed to me, and can easily lead to a PC getting angry or losing interest in the session. In cases like the doppelganger, where the PC would have been incapacitated at some point and replaced, the player might wonder why they never got a chance to fight back. Worse, it lets the other players know that the character has lost agency in cases where their characters might have no way of knowing that.
What are some alternative methods for using these spells and monsters in a way that keeps the player of the controlled character involved and invested in the action and does not reveal anything to the group that they should not know?