How to get the value of a taxonomy term from entity reference using a token?
You try use hook_tokens

    /**
     * Implements hook_tokens().
     */
    function mymodule_tokens($type, $tokens, array $data, array $options, \Drupal\Core\Render\BubbleableMetadata $bubbleable_metadata) {
$replacements = array();
// $type is token type
      if ($type == 'node' &amp;&amp; !empty($data['node'])) {
        foreach ($tokens as $name =&gt; $original) {
      // to do
        $replacements[$original] ='xxx';
       }
      }
      return $replacements;
    }


See more api hook_tokens()