Pedro;
GAM, of either flavor, has no mechanism to do embedded loops, other than the ability to iterate over a csv file. There are two potential ways to tackle this, they are variations on a theme.
First, you can use whatever shell you are using to loop over the groups and members and execute a single gam command for each group/member pair. Second, you can install advanced gam as a python library and essentially do as suggested in the first suggestion. You would still be building up each gam command individually, then using exec to invoke each command, or you could send each constructed command to a file which could be executed using the gam batch capability, my personal preference in most scenarios.
Here is an example using the bash shell. It's a pretty ugly almost one liner. This sample sends each constructed gam command to stdout, you can collect all the commands into a gam batch file. I'm sure you can do something similar with powershell. Sometimes you just have to wrap what you want to do in a script.
# Array of colors
Colors=(
'#16a765'
'#ffdeb5'
)
# get all members of all groups, then add the labels with random color selection
gam redirect csv - print group-members fields group,email|tail -n +2|(IFS=\,;while read group member;do echo gam group \"$group\" add label \"$member\" labellistvisibility showifunread backgroundcolor \"$(echo ${Colors[$(shuf -i 0-23 -n 1)]})\" textcolor \"$(echo ${Colors[$(shuf -i 0-23 -n 1)]})\";done)
Hopefully you will find this useful, or at least entertaining. It was an interesting diversion anyway.