Hello @sahil.anand - Thanks for reaching out, and engaging the MS Q&A community.I believe that your question isn't really specific to Service Bus, rather, it seems a general Microsoft Entra ID-specific question concerning how to programmatically grant cross-tenant access.
Here's the official doc: Overview of Microsoft Entra External ID
As you've already discovered, B2B collaboration supports invite-based user sign-up/registration. However, if the programmatic way is a must in your scenario, the doc states the following on the matter:
Use Microsoft Entra entitlement management, an identity governance feature that lets you manage identity and access for external users at scale by automating access request workflows, access assignments, reviews, and expiration.
I recommend exploring the above first. If it seems like overkill, Azure Service Bus supports SAS token-based access as well: Service Bus access control with Shared Access Signatures