Create a link pointing to #
It's probably not possible to attach an empty fragment. See this code in  UrlGenerator::generateFromRoute():

if (isset($options['fragment'])) {
  if (($fragment = trim($options['fragment'])) != '') {
    $fragment = '#' . $fragment;
  }
}


If the fragment is empty it is ignored and no '#' shows up. This doesn't change if you provide the fragment in Url::fromUserInput(), because the fragment is transfered to the options and later processed by the same or similar code.

So you have to provide an anchor in the fragment:

$url = Url::fromUserInput('#anchor1');


or

$url = Url::fromRoute('&lt;current&gt;', [], ['fragment' =&gt; 'anchor2']);


As alternative option you can place a link with an empty fragment

&lt;a href="#"&gt;{{ examplevariable }}&lt;/a&gt;


either in a twig template or in an inline template in php.