How can I create this menu with wp_nav_menu()?

This can achieve with a nav walker. I used this. I am stepping according to the mentioned.

  1. Put navwalker (wp-bootstrap-navwalker.php) in your theme root
  2. Call to the navwalker in functions.php file. require_once('wp-bootstrap-navwalker.php');
  3. Create your menu in WordPress Backend (Appearance -> Menus)
  4. In your menu area, according to me in header.php
wp_nav_menu( array(
  'menu' => 'main_menu',
  'depth' => 2,
  'container' => false,
  'menu_class' => 'nav navbar-nav navbar-center',
  'walker' => new wp_bootstrap_navwalker())
);
`main_menu` is my menu name