The DM isn't telling you how to play your character. The DM is making a suggestion as to how you might want to change the way you play your character, as an alternative to no longer being invited to their game.
Which in effect boils down to the same thing: play my way or go home.
Re: secretly following party:
If the DM OKed the character getting booted because the way that you were playing them was disruptive to the game on the OOC level, they are likely to not allow that option.
OK, first off, the DM has no say whatsoever in whether a
character gets booted from a party (unless the DM has one or more NPCs in the party who could, along with the PCs, voice an opinion based on their established character).
And, even if a character gets booted from a party it still a) is a character existing in the game world and b) has a player attached. So until-unless the player turns that PC over to the DM to use as an NPC that character still belongs to the player.
I'm not saying any session time needs be spent on sorting out what that character does next (other than maybe a short exchange of notes between player and DM so the DM knows what the player has in mind), but at some point the player and DM would sit down over a beer and update that PC or do it by email.
Most games that I'm aware of are no-PVP from session zero/social contract. The DM has a remit to work against the characters, which is going to have the potential to kill them, but still might try to avoid specific issues that would cause the player to no longer enjoy playing that character.
Because characters are played by the players, their behaviour will be constrained by the meta-contract that constrains the players.
This is what I disagree with.
The social contract quite rightly tells me I can't just reach across the table, haul off and punch Bob in the face. But there's absolutely nothing saying my character Eohyl can't haul off and punch Bob's character Falstaff in the face, even though Bob and I might otherwise be the best of friends.
Please bear in mind that this is not about harmless inter-party shenanigans, or agreed-upon PVP in a PVP game.
Its not about something the player can just laugh off.
Actually, yes it is; as it's the harmless shenanigans and PvP that can be (and IME are) laughed off that are what people seem to want to ban; and I'm not cool with that.
It might be an action that strikes too close to an issue that the player has had to deal with. It might be a potentially long-term change to something that the player regards as a core part of the identity of a well-loved character.
This is about doing something to the character that actively upsets the player.
As in you are choosing for your character to do something to their character that you know will upset the player.
As in you are choosing to upset the player. - Who presumably was a friend.
Other than the bolded bit, this is a whole different element, recently discussed to death in a few threads regarding X-cards and triggering and so forth; and no, upsetting a real-world player due to real-world issues is not my intention.
But the piece about the long-term change to a well-loved character? Happens all the time as a known part of the game; the only difference here is that the source of said change might be another PC rather than something in the setting (e.g. trap) or opposition.