Custom markup with wp_nav_menu based on pages

The only way that I could think to do this would be to add a filter to wp_nav_menu_items. Here is the code that I got to work (just add it to your themes functions.php file):

add_filter('wp_nav_menu_items', 'my_id_name_nav', 10, 2);
function my_id_name_nav($items,$args) {
  if( $args->theme_location == 'primary' ) {
    preg_match_all('/<li id="menu-item-([0-9]+)"([^>]+)>\s*<a href="https://wordpress.stackexchange.com/questions/13867/([^"]+)">([^<]+)<\/a><\/li>/i', $items, $matches);
    $newItems = array();
    for($i=0; $i<count($matches[0]); $i++){
      $short = explode("https://wordpress.stackexchange.com/", $matches[3][$i]);
      $short = $short[count($short) - 2]; // if there is no trailing slash, subtract 1 instead of 2
      array_push($newItems, '<li id="menu-item-'. $short .'"'. $matches[2][$i] .'><a href="'. $matches[3][$i] .'">'. $matches[4][$i] .'</a></li>');
    }
    return implode('', $newItems);
  } else {
    return $items;
  }
}

It uses the last part of the url to create the page name for the id. So menu-item-2 for http://yoursite.com/page1/page2/ would become menu-item-page2.

The if( $args->theme_location == 'primary' ) is for targeting a specific menu. If you want to do this for all menus just remove the if else statement.