You can use the activity "Group choice", so that students can register for a group on their own. At least two groups must be present in the course first.
To create groups:
Select the item "Groups" from the "Main Menu" on the left.
With the help of "Create group" or "Auto-create groups" you can create the desired number of groups.
Click on the name of your course in the "Main Menu" to return to the "main page" of the course.
To create the "Group choice":
Click on "+ Add an activity or resource" in the desired section.
Select the activity "Group choice" from the list and click on "Add".
To create a group with a maximum of 3 members, select "Enable" under "Limit the number of responses allowed".
Enter 3 in the "General limitation" field.
Under "Groups", add the groups for which students should register.
Finally, click on "Save and return to course".