What is the alternative of hook_custom_theme in Drupal 8? I need to change the theme based in custom criteria.

Some nodes should be displayed with one particular theme and others with the admin theme.

In D7 I could simply use the pathauto module and set the node url to admin/[node-title]. It works in D7 because all url starting in admin will use the admin theme in D7.

An alternative way to do the same thing would be to use the hook_custom_theme() function in D7. I did not find any similar function in D8.
That is a service now. See \Drupal\user\Theme\AdminNegotiator for an example, which is registered as a tagged service:

theme.negotiator.admin_theme:
  class: Drupal\user\Theme\AdminNegotiator
  arguments: ['@current_user', '@config.factory', '@entity.manager', '@router.admin_context']
  tags:
    - { name: theme_negotiator, priority: -40 }