I’ve had success using Homebrew in a multi-user environment the following way:
Create a new (non-GUI) user, group and home directory:
sudo /usr/sbin/sysadminctl -addUser brew \
-fullName 'Homebrew' -admin -home /var/brew \
-password - -UID 430 \