Building, integrating, or customizing apps and workflows within Microsoft Teams using developer tools and APIs
MS Graph, for now, doesn't support this query from the autonomous application, and only the user can query this data.
My workaround is: get installed applications from the user who has already installed the app and read the id from the result.
const { Client } = require("@microsoft/microsoft-graph-client");
const client = Client.init({ ... });
const response = await client
.api(`/users/${userId}/teamwork/installedApps`)
.expand("teamsApp")
.filter(`teamsApp/displayName eq '${appName}'`)
.get();
const internalAppId = response?.value[0]?.teamsApp.id;