Yes, it is possible. What you have to understand is that the function is just a code running on a computer, regardless of where it is. Therefore, all you need to do is provide the function the details of the App Registration and ensure that the function does not have any network limitations for connecting to the graph Api. (or any Api that you are wanting to connect to for that matter)
Here is an example function https://learn.microsoft.com/en-us/samples/microsoftgraph/msgraph-sample-azurefunction-csharp/microsoft-graph-sample-azure-function.
This sample demonstrates how to use the Microsoft Graph .NET SDK to access data in Office 365 from Azure Functions.
Something to keep in mind is that the client secret isn't stored in the code, but referenced from a key vault within the functions application settings. Also make sure that the App Registration is created in Tenant B.
I hope this helps provide you with the information you need. If it does, please make sure to mark the question as answered so it helps other people in future.
Kind regards
Alistair