First your as administrator would need to setup a trust relationship between domain an and b. This would allow domain a to trust a domain b authentication.
https://learn.microsoft.com/en-us/entra/identity/domain-services/concepts-forest-trust
once this is done you can enable domain b users and groups.