Drupal 8: Create a Twig Template Theme Hook

In the code below, $vars['elements']['#view_mode']; was derived from using kint($vars) under this function to see the view mode array for a user. This code is added to your theme's .theme file. Run drush cr and then you will then see the new theme suggestions appear within Twig debugging.

For example, if I've set "full view mode" for users user--full.html.twig shows up. if you have a view mode for user, "compact", then a suggestion of user--compact.html.twig will show up.

/**
 * Implements hook_theme_suggestions_user_alter().
 *
 *   An array of alternate, more specific names for template files or theme
 *   functions.
 */
function MYTHEME_theme_suggestions_user_alter(&$suggestions, $vars, $hook) {

  // Define the view mode.
  $mode = $vars['elements']['#view_mode'];

  // Create a theme hook suggestion which has the view mode name in it.
  $suggestions[] = 'user__' . $mode;
}