You could set up a PowerShell command that schedule runs and updates groups:
Add-UnifiedGroupLinks
(with the -LinkType switch set to owners)
Example (Teacher in Classroom A):
$users= Get-User -ResultSize unlimited | where {$_.Department -eq "Classroom A" -AND $_.RecipientType -eq "UserMailbox" -AND $_.jobTitle -eq "Teacher"}
Add-UnifiedGroupLinks -Identity Marketing -LinkType owners -Links ($users.UserPrincipalName)
In the example, you would need to create a for-loop that would either go through a spreadsheet or database (table) that has all of your classrooms listed.
Add-UnifiedGroupLinks (Documentation)
--------------------------------------------------
If this is helpful please accept answer.