How to add a custom PHP library as a non-GitHub composer package to a custom Magento 2 extension?

Composer supports a lot of repository types, not only GutHub: How to install an extension not from a Git repository?