How do I programmatically render a menu's label? I'm trying to render out a menu with its label in Drupal 8. I am able to get the menu and its links inside of a preprocess function using a helper function, but I can't locate the menu's title.

Here is how I'm getting the menu. I'm able to add the return value as a twig variable $variable['menu']['menu-name'] and render out an &lt;ul&gt; anywhere I need to.

function get_menu($menu_name) {
  $menu_tree = \Drupal::menuTree();
  $parameters = $menu_tree-&gt;getCurrentRouteMenuTreeParameters($menu_name);
  $tree = $menu_tree-&gt;load($menu_name, $parameters);
  $manipulators = array(
    // Only show links that are accessible for the current user.
    array('callable' =&gt; 'menu.default_tree_manipulators:checkAccess'),
    // Use the default sorting of menu links.
    array('callable' =&gt; 'menu.default_tree_manipulators:generateIndexAndSort'),
  );
  $tree = $menu_tree-&gt;transform($tree, $manipulators);
  $menu = $menu_tree-&gt;build($tree);

  return array('#markup' =&gt; drupal_render($menu));
}
Here is the snippet to change the menu name:

 function example_preprocess_menu(&amp;$variables) {
      $element = &amp;$variables['items'];
      foreach ($element as &amp;$item) {
        if ($item['original_link']-&gt;getMenuName() == 'menu-machine-name') {
        //For the menu label    
       $menu = entity_load('menu', 'menu-machine-name');
          $menu_label = $menu-&gt;label(); 
          if ($item['title'] == 'Example menu') {
            $item['title'] = 'New menu name';
          }
        }
      }
    }