uri – How can I create a Link to an URL containing a fragment identifier?

Please see public static function Link::createFromRoute

array $options: The options parameter takes exactly the same structure. See DrupalCoreUrl::fromUri() for details.

You can pass a 4th argument as an array with a fragment key value:

Link::createFromRoute($this->t('Title'), 'entity.node.canonical', ('node' => 77), ('fragment' => 'example'));