How to get the correct 'base hook' to override a template file in a custom module?
Look into the *.module file where the base hook is defined, in this case the User module. The base hook is the key of the template definition:

user.module:

/**
 * Implements hook_theme().
 */

function user_theme() {
  return [
    ... 
    'username' =&gt; [
      'variables' =&gt; ['account' =&gt; NULL, 'attributes' =&gt; [], 'link_options' =&gt; []],
    ],
  ];
}


Then in your *.module file

mymodule.module

/**
 * Implements hook_theme().
 */
function mymodule_theme() {
  return [
    'username__mymodule_template' =&gt; [
      'base hook' =&gt; 'username',
    ],
  ];
}


Start the name of your own hook  with the base hook and double underscores.