No, you can't change the license, but you can clone the permission set using vs code.
Get your existing permission using package.xml
Now, follow the below process to clone the Permission Set.
In the permission set folder, you will get the meta XML ...
In short: I managed to do this in Apex by using apex-mdapi AFTER I updated the code to support flowAccesses. - here's the github commit with changes needed to support it. This is the only way I can see to do this through Apex as you need to hit the Metadata API.
Very Long Version
I didn't see anything within SOQL or Tooling API that can be used. It seems ...
Salesforce support told us that this is an error in the documentation, which they will correct.
The "checkPermission" method inside a managed package will only be able to verify the custom permissions of the package itself.
To get around this, you need to implement the "workaround" solution with 2 queries.
I don't fully agree with this choice/answer, but ...
As pointed out by @davidreed - the user making the change must have a license assigned to the managed package. Any user, even without the managed package license, can query the FieldPermission object and see all records across all packages, but only users with an assigned license can make updates to FieldPermission records.