Code snippet that can be used to create a menu item without a link in drupal 8.
In Admin UI
you need to use
route:<nolink> to achieve this.
you can create a link programmatically using Link::fromTextAndUrl not linkable like that: