You can use the following query to list only licensed users:
https://graph.microsoft.com/v1.0/users?$filter=assignedLicenses/$count
Do note that this is an "advanced" query, thus it requires the consistencyLevel=eventual header:
https://learn.microsoft.com/en-us/graph/aad-advanced-queries?tabs=http