Sharing a couple of commands I found useful for exporting and updating Google Group Dynamic Queries. This was pieced together from different parts of the documentation, but I didn't find a single source with these (sharing for my future self :)
Get existing dynamic group queries
gam redirect csv ./cigroups.csv print cigroups query "'cloudidentity.googleapis.com/groups.dynamic' in labels" fields dynamicgroupmetadata
Modify the cigroups.csv as required
Update Dynamic group queries
gam csv ./cigroups.csv gam update cigroup "~email" dynamic "~dynamicGroupMetadata.queries.0.query"
Hopefully useful and welcome and feedback/questions