Adding a variable to a menu twig template
You could use directly the derivative id (which will be unique) of the menu item in twig, with:
item.original_link.getDerivativeId()

otherwise you need to add a custom unique id in preprocess function to each item, like:
function yourtheme_menu_link_alter(&amp;$item) {
  if($item['menu_name'] == 'custom-menu')
  {
    $item['uuid'] = \Drupal\Component\Utility\Html::getUniqueId($item['menu_name']);
  }
}

which you then access in twig with:
item.uuid