Hi - OK so you want to create the HC Relay via an ARM management (control plane) call from the function to facilitate comms from point A to point B (but not from the function itself, that's just a wrapper for creating the HC in this case?)
(Let me know if i got that right or wrong)
As it's a management operation the best practice would be to use the identity lib (your example was JS so you need the JS version linked above) to return a token - the managed identity would be fine as it's the identity the function runs under and that makes sense here
For RBAC , what role you need to grant the MSI , see here https://learn.microsoft.com/en-us/azure/azure-relay/authenticate-managed-identity#azure-built-in-roles-for-azure-relay