Dear SGTPrasad,
Good day!!
As per the description shared, I understand your concern and to my knowledge, we can get the GUID of the SharePoint Online site via adding the following _api/site/idat the end of the Site URL:
https://companyname.sharepoint.com/sites/sitename/_api/site/id
For example:
Moreover, I found an article that provides three other methods such as PowerShell, Power Automate, Microsoft Graph API and here is the reference: 4 Ways to Check SharePoint Site ID - Power Tech Tips
However, if you are looking for an alternative way, as there is no out of the box solution, I request you to connect with the SharePoint Development experts via posting your concern in the SharePoint Developer - Microsoft Community Hub & Questions - Microsoft Q&A with SharePoint Development tag to get the opinions from the experts.
In addition, I will keep this thread open so that MVPs and experts in this community will share the ideas on your concern.
Appreciate your patience and understanding. Have a great day!!
Best Regards,
Sophia