Common Custom PHP Library: Drupal 8 and Stand-alone Shell Scripts
It's possible to pull custom php libraries into your project with composer. You'll need to define the repository in the repositories section. Checkout handling private packages and repositories in composer's documentation. It's really fairly easy. If you have a single github repo you can include the repository info like below:

"repositories": [
    {"type": "composer", "url": "https://packages.drupal.org/8"},
    {"type": "vcs", "url": "https://github.com/myorg/mypackage"}
]


You should include a composer.json file in your repo as you'd probably expect. Here is a simple one to get you started:

    "name": "myorg/mypackage",
    "description": "My Package is the greatest!",
    "license": "proprietary",

    "autoload": {
        "psr-4": {"Myorg\\Mypackage\\": "src/"}
    }


Now your code can by placed in scr/Myclass.php with a 

namespace Myorg\Mypackage;

Class Myclass {}


Choosing which version to pull in is a little but confusing. When you include a branch you need to prefix the branch nave with dev-, e.g. dev-master for the master branch. Otherwise, you can create tags and pull them in by their name, e.g. 1.0.0, etc. I've used this technique successfully with bitbucket.

Some inclusion examples where your composer.json in your repo defines your package name as myorg/mypackage:

// This will pull whichever branch is marked as the "default" branch in your repo
composer require myorg/mypackage

// This will pull the "develop" branch
composer require myorg/mypackage:dev-develop

// This will pull in the "2.1.3" tag
composer require myorg/mypackage:2.1.3

// You can also use "^" and "~" with tags
composer require myorg/mypackage:^2.1.0


You can tell composer where to put your package by adding a new item to the extra.installer-paths section of composer.json. For example, if you want to install your package to web/modules/custom add a line like:

"extra": {
    "installer-paths": {
        "web/modules/custom/{$name}": ["vendor:myorg"],
        ...
        "web/core": ["type:drupal-core"],
        ...
    }
}


If your repos are private, you may have some issues pulling your repo as a package. I've worked around this issue by using my ssh key for access to the repos and making sure anyone who runs composer require myorg/mypackage also uses the ssh key method.

An alternate technique is to create a zip release of your package and include it as a repository as the chosen module's README explains.