1.To remove the "Add shortcut to OneDrive" button in the command bar, you could run following PowerShell as administrator.
Note: This PowerShell removes the “Add Shortcut to OneDrive” button from all sites in the tenant (Not on a specific site).
Connect-SPOService "https://tenant-admin.sharepoint.com"
Set-SPOTenant -DisableAddShortCutsToOneDrive $True
2.JSON codes allow basic changes to the command bar, including modification of icon or text, hiding existing options or repositioning commands.
But Favorite is not the valid key in the command bar. So, there is no option to remove Favorite button in the command bar.
Valid keys: https://learn.microsoft.com/en-us/sharepoint/dev/declarative-customization/view-commandbar-formatting#key
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.