You'll use a for loop to iterate over the groups.
Something like this;
param groupIds array = ['123', '456']
var AcrPullRole = subscriptionResourceId('Microsoft.Authorization/roleDefinitions', '7f951dda-4ed3-4680-a7ca-43fe172d538d')
resource aks_acr_pull 'Microsoft.Authorization/roleAssignments@2022-04-01' = [for groupId in groupIds: {
name: guid('resourceId', groupId, AcrPullRole)
properties: {
roleDefinitionId: AcrPullRole
principalId: groupId
}
}]