There are many reasons you would need to find the team or bundle id of a specific macOS package, the one I stumbled upon recently was to use them when creating a PPPC profile that whitelists the application and approves its extensions without the need of user approval.
Find the bundle id
There are three (possibly more) different methods to find the bundle id of a macOS package these are:
osascript -e 'id of app "Finder"'
Look for a key named CFBundleIdentifier, the bundle id will be a string on the line below it.
Using Online Tools
There are some online websites that can help you find the bundle id of an app (example), just search for the app name and you will get the information.
Find the team id
Just as with the bundle id, there are multiple ways to find this identifier, here are the ones I know of:
codesign -dv --verbose=4 /Applications/Firefox.app
Look for TeamIdentifier, that's the one.