A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.
Since you're able to connect and pull user and group information without any issues, I don't think authentication is the problem. I'd look more closely at the permissions and custom write scope.
One thing I'd try is creating a temporary cloud-only distribution group without the custom scope and seeing if the runbook can add a member to it. If that works, you've pretty much narrowed it down to the scope configuration.
I'd also double-check the Exchange role assignments using Get-ManagementRoleAssignment. Having Exchange.ManageAsApp and the admin roles assigned doesn't necessarily mean the identity has the correct write permissions for that specific group.
Also, is this distribution group cloud-only or synced from on-prem AD? That could make a big difference. The generic server error isn't much help, so I'd grab the full error details and request ID as well.