Hello @Denis, When tested I faced the similar issue when creating SharePoint site permission via Microsoft Graph API.
I got the same error when I passed application ID of TestAppA:
POST https://graph.microsoft.com/v1.0/sites/domain.sharepoint.com:/sites/RukSite:/permissions
{
"roles": [
"read"
],
"grantedToIdentities": [
{
"application": {
"id": "AppID"
}
}
]
}

But when I passed application ID of TestAppB it worked:

Hence to resolve the issue, as a workaround, I modified the request body as mentioned in this Microsoft Document: Create permission - Microsoft Graph v1.0 | Microsoft by passing the displayName too in the request body.
For the TestAppA, for which I was getting the error I passed displayName the request body as below:
POST https://graph.microsoft.com/v1.0/sites/domain.sharepoint.com:/sites/RukSite:/permissions
{
"roles": ["read"],
"grantedToIdentities": [{
"application": {
"id": "TestAppAAppID",
"displayName": "Test"
}
}]
}

Hence to resolve the issue pass displayName in the request body for all the applications while creating SharePoint site permission via Microsoft Graph API.
I tested the same for several applications and by passing the displayName in the request body and the API call is successful.
Hope this helps!
If this answers your query, do click Accept Answer and Yes for was this answer helpful, which may help members with similar questions.
If you have any other questions or are still experiencing issues, feel free to ask in the "comments" section, and I'd be happy to help.