How to use a relative path for a theme's favicon
another idea for a workaround would be to overwrite the href property on runtime with hook_page_attachments_alter, somethng like this:

function MYTHEME_page_attachments_alter(array &amp;$page) {
     foreach($page['#attached']['html_head_link'] as $k =&gt; $v) {
          if (array_key_exists('rel', $v[0]) &amp;&amp; $v[0]['rel'] == 'shortcut icon') {
                  $page['#attached']['html_head_link'][$k][0]['href'] = drupal_get_path('theme', 'MYTHEME') . 'static/favicon.png';
          }
     }
}


or use the default favicon path (MY_THEME/favicon.ico), it will be taken, see this source:

// Generate the path to the favicon.
      if ($cache[$theme]-&gt;get('features.favicon')) {
        $favicon_path = $cache[$theme]-&gt;get('favicon.path');
        if ($cache[$theme]-&gt;get('favicon.use_default')) {
          if (file_exists($favicon = $theme_object-&gt;getPath() . '/favicon.ico')) {
            $cache[$theme]-&gt;set('favicon.url', file_url_transform_relative(file_create_url($favicon)));
          }
          else {
            $cache[$theme]-&gt;set('favicon.url', file_url_transform_relative(file_create_url('core/misc/favicon.ico')));
          }
        }
        elseif ($favicon_path) {
          $cache[$theme]-&gt;set('favicon.url', file_url_transform_relative(file_create_url($favicon_path)));
        }
        else {
          $cache[$theme]-&gt;set('features.favicon', FALSE);
        }
      }