Quick commands to create user and group in macOS with specific uid and gid, and to add a specific user to newly created group.
sudo dscl . -create /Groups/<name> gid <gid>
sudo dscl . -create /Users/<name>
sudo dscl . -create /Users/<name> UniqueID "<uid>"
sudo dscl . -create /Users/<name> PrimaryGroupID <gid>
Add existing user to new group
sudo dscl . append /Groups/<name> GroupMembership <user>
Wish macOS actually used useradd/groupadd like linux systems, ah well!