The following exception is thrown when the Dev Hub org is not authorized while creating the scratch org.
Make sure that the org with username and ID is enabled as a Dev Hub. To enable it, open the org in your browser, navigate to the Dev Hub page in Setup, and click Enable.
To resolve the issue, use the following command to login and set the Dev Hub org an alias.
sfdx force:auth:web:login -d -a DevHub
You can change DevHub to a different name if needed.
Once the Authentication is successful using the above command, the scratch org creation should succeed without any issues.