The best working way so far (with some additions) from here:
https://joshhall.co/how-to-create-a-divi-mobile-menu-collapse-effect/
/********* Mobile Menu Collapse ********/
/**** This hides the sub menu items on mobile ****/
#main-header .et_mobile_menu li ul.hide {
display: none !important;
}
/**** This adjusts the positioning and the background transparency of the parent menu item on mobile ****/
#mobile_menu .menu-item-has-children {
position: relative;
}
#mobile_menu .menu-item-has-children > a {
background: transparent;
}
/**** This styles the icon and moves it to the right ****/
#mobile_menu .menu-item-has-children > a + span {
position: absolute;
right: 0;
top: 0;
padding: 10px 20px;
font-size: 20px;
font-weight: 700;
cursor: pointer;
z-index: 3;
}
/**** Here you can swap out the actual icons ****/
span.menu-closed:before {
content: "c";
display: block;
color: #fff;
font-size: 16px;
font-family: ETmodules;
}
span.menu-closed.menu-open:before {
content: "d";
}
.mobile_nav.opened .mobile_menu_bar::before {
content: "d";
}
<script type="text/javascript">
(function($) {
function setup_collapsible_submenus() {
// mobile menu
$('#mobile_menu .menu-item-has-children > a').after('<span class="menu-closed"></span>');
$('#mobile_menu .menu-item-has-children > a').each(function() {
$(this).next().next('.sub-menu').toggleClass('hide',1000);
});
$('#mobile_menu .menu-item-has-children > a + span').on('click', function(event) {
event.preventDefault();
$(this).toggleClass('menu-open');
$(this).next('.sub-menu').toggleClass('hide',1000);
});
}
$(window).load(function() {
setTimeout(function() {
setup_collapsible_submenus();
}, 700);
});
})(jQuery);
</script>