In Drupal 8, pathauto patterns are [configuration entities][1]. You have  at least two choices to provide them with your custom module:

(1) Provide your pattern as YAML configurations in your module's `config/install` folder. They will be considered and installed to your Drupal, when your module will be installed. Easiest to create using the UI and doing a configuration export afterwards. Just remove the generated UUID of the pattern.

(2) On run-time or in your install/update hooks, you can use `Drupal\pathauto\Entity\PathautoPattern::create()` or the [\Drupal::entityTypeManager()][2] to create them dynamically:

    $data = [
      'id' => 'my_pattern_machine_name',
      'type' => 'canonical_entities:node',
      'pattern' => 'my-path/[node:title]',
      'weight' => 0,
    ];
    $pattern = \Drupal::entityTypeManager()->getStorage('pathauto_pattern')->create($data);

You can then use the returned pattern entity in `$pattern` to add selection conditions (e.g. bundles, language, ...) as required. Don't forget to save the entity afterwards, and - of course - check, if the pathauto module has been installed before or make it a dependency of your custom module.


  [1]: https://www.drupal.org/docs/8/api/entity-api/configuration-entity
  [2]: https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Entity%21EntityTypeManager.php/class/EntityTypeManager/8.5.x