Zend certified PHP/Magento developer

Trouble using dscl to create and add user to group

I am working on a fix for a piece of software where the provider suggests we should create a user group with dscl and then grant the group ownership of a folder.

Users in our environment are on macOS 12+.

So far, I am using zsh to determine $LIVEUSER and running the following:

dscl . create /groups/appname

dscl . -append /groups/appname GroupMembership $LIVEUSER

This does not seem to be working as intended. The command returns with no errors, and when I run:

dscacheutil -q group -a name appname

The command finishes with no output. Running something like:

dscacheutil -q group -a name admin

Returns the name, password, gid, and users within the group.

How can I use dscl to create a group and add a user to that group successfully?