If the error shows up during the configuration of AD Connect please verify the prerequisites first: https://learn.microsoft.com/en-us/azure/active-directory/hybrid/how-to-connect-install-prerequisites
I am aware of this issue at different environments because of issues with the Azure Global Administrator account in Azure AD. Never had problems using an "Azure AD only account" for setup.
Also please check the log file mentioned in the Setup Wizard.
----------
(If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)
Regards
Andreas Baumgarten