Add attribute to main menu item
You can use this HOOK_menu_link_alter and add new attribute from there.

https://api.drupal.org/api/drupal/modules!system!system.api.php/function/hook_menu_link_alter/7

function MYMODULE_menu_link_alter(&amp;$item) {
  if ($item['link_path'] == 'user/login') {
    $item['options']['attributes']['data-toggle'] = 'modal';
    $item['options']['attributes']['data-target'] = '#login-modal';
  }
}


Note : Make sure you clear cache and are checking this for anonymous user.