Give every name a team
Names are shuffled, then dealt across the teams. Team count fixes how many teams you get. Maximum team size works out the team count first. Extra names are spread among the first teams.
A worked example
Five people split into two teams make one team of three and one of two. A maximum size of two makes three teams with sizes two, two and one. To pick one person from a team next, draw from its names.
Before you use the result
Skill levels and keep-apart pairs are not considered. Duplicate lines count as separate people, so check the input before making teams.