Thinking better I think you may not need one policy per group, maybe you could just use the same policies, but in the custom field uses an environment variable.
This environment variable would need to exist on every machine and be a system level variable that the elastic agent process would have access.
Check this answer on a similar post.