Hi,
Is this the new error occurred after you upgraded to latest RDC for mac?
When checking the release of RDC for mac 10.4.1, it mentioned to address the 0x5000007 error message when connecting using an RD Gateway server.
Have you tried to remove and re-fillin the RD gateway info when start the remote connection?
If it used to work well with previous version, you may test by download similar Beta version as workround and report the new issue you met.
Microsoft Remote Desktop Beta
https://install.appcenter.ms/orgs/rdmacios-k2vy/apps/microsoft-remote-desktop-for-mac/distribution_groups/all-users-of-microsoft-remote-desktop-for-mac
Hope this helps and please help to accept as Answer if the response is useful.
Thanks,
Jenny