How can I rename a menu machine name in drupal 8
I also faced the problem when I needed to rename the machine name of my custom menus. In my case, I needed to remove hyphens in the machine name (this is a known issue https://www.drupal.org/project/drupal/issues/1353064), because some modules don't support hyphens. How I fixed it:

First of all you need to update already existing menu items (bundle, name, parent and etc.) I did it directly in a database through hook_update in your_custom_module:

function your_custom_module_update_8008() {
  $database = \Drupal::database();

  $menus = [
    'example-menu-machine-name-1' =&gt; 'examplemenumachinename1',
    'example-menu-machine-name-2' =&gt; 'examplemenumachinename2',
  ];

  foreach ($menus as $old_machine_name =&gt; $new_machine_name) {
    $database-&gt;update('menu_link_content')
      -&gt;expression('bundle', &quot;REPLACE(bundle, :old_value, :new_value)&quot;, [
        ':old_value' =&gt; $old_machine_name,
        ':new_value' =&gt; $new_machine_name,
      ])
      -&gt;execute();
    $database-&gt;update('menu_link_content_data')
      -&gt;expression('menu_name', &quot;REPLACE(menu_name, :old_value, :new_value)&quot;, [
        ':old_value' =&gt; $old_machine_name,
        ':new_value' =&gt; $new_machine_name,
      ])
      -&gt;expression('bundle', &quot;REPLACE(bundle, :old_value, :new_value)&quot;, [
        ':old_value' =&gt; $old_machine_name,
        ':new_value' =&gt; $new_machine_name,
      ])
      -&gt;execute();

    $database-&gt;update('menu_tree')
      -&gt;expression('menu_name', 'REPLACE(menu_name, :old_value, :new_value)', [
        ':old_value' =&gt; $old_machine_name,
        ':new_value' =&gt; $new_machine_name,
      ])
      -&gt;expression('id', 'REPLACE(id, :old_value, :new_value)', [
        ':old_value' =&gt; $old_machine_name,
        ':new_value' =&gt; $new_machine_name,
      ])
      -&gt;expression('parent', 'REPLACE(parent, :old_value, :new_value)', [
        ':old_value' =&gt; $old_machine_name,
        ':new_value' =&gt; $new_machine_name,
      ])
      -&gt;execute();
  }
}


Rename these names in configs. Your IDE should help with this. Don't forget also about renaming files for configs. For example:
system.menu.example-menu-machine-name-1.yml to system.menu.examplemenumachinename1.yml

If you have custom templates for menus also rename them:
menu--example-menu-machine-name-1.html.twig to menu--examplemenumachinename1.html.twig

Adjust classes in CSS|SCSS files, because they will be changed after renaming. Use IDE for this, it will save time :)

Run your build process locally and check results.

Take the dump of the database from the production and run a build with this database locally. Please compare menus between the local version and the production on the frontend.