If I'm not wrong your use cases maybe matches triggering a Zitadel Action that performs the request against your service to obtain the group-id claims, that would be done on Flow Type "Complement Token" and "Pre access token creation" trigger. The action code would use zitadel/httpzitadel/http module to perform the request and api.v1.claims.setClaim(key, value)api.v1.claims.setClaim(key, value) to set the claim. https://zitadel.com/docs/apis/actions/code-examples#set-hardcoded-claim
Regarding the secrets I'm also concerned about it, I didn't find a way to dynamically resolve any kind of env variables from actions code, unless fetching them from another HTTP server or implementing some kind of "internal API server" (not exposed to public traffic) that is able to resolve secrets as needed and perform the request to other protected endpoint (ie: zitadel action -> internal API -> protected API).
Preflight Checklist I could not find a solution in the existing issues, docs, nor discussions I have joined the ZITADEL chat Describe your problem Currently users can't pull secret values into ...