I have been able to generate my UAMI bearer token using Azure Function.
I needed to link my UAMI to my Azure Function.
This link tells that Azure Function is the only way to get bearer token in ADF as ADF REST API will not work for this.
https://stackoverflow.com/questions/75401557/getting-access-token-for-azure-managed-identity-in-azure-datafactory-as-text
I have been successfully able to submit MT Spark job via Livy API.