Dependency injection on module.install
Yes, for procedural code in hooks you have to use the static service container wrapper \Drupal. Either to get a service or to use one of the predefined static functions. See for example:

shortcut.install

/**
 * Implements hook_install().
 */
function shortcut_install() {
  // Theme settings are not configuration entities and cannot depend on modules
  // so to set a module-specific setting, we need to set it with logic.
  if (\Drupal::service('theme_handler')-&gt;themeExists('seven')) {
    \Drupal::configFactory()-&gt;getEditable('seven.settings')-&gt;set('third_party_settings.shortcut.module_link', TRUE)-&gt;save(TRUE);
  }
}