Can you limit the number of players in a game?

For example, if a game supports up to 4 players, can you have an option that limits the number of players to 2 so players can’t change player side to the remaining 2?

Let’s say the player sides are: Player1, Player2, Player3, Player4.

I’m looking for a way to limit the number of players at the start of the game, so for a 2 players game you can join only as Player1 and Player2.