Let’s start with a question, can megamenu be enabled on all site templates?
Well answer is No, it is available only on SharePoint Hub sites which are associated with Microsoft teams or on Communication sites.
What is a megamenu in SharePoint Online?
In the traditional navigration structure you could only have two levels of navigation but now in MegaMenu you can have multiple levels spanning horizontally and vertically.
How it works?
You can create MegaMenu from Site Settings –> Change the look –> Navigation. Note that MegaMenu is default type in Communication sites but if you need to change it follow below steps
MegaMenu can be used to create multi-level horizontal and vertical menus as shown below.
To start with you need to click Edit on right side and Under any heading, when you hover you will see a line with plus symbol to add a menu. Use that to add headers or links depending on what you need.
Once done you can “Make sub link” to make it appear under it
Sample final outcome
How about Security trimming and Audience targeting in MegaMenu in Hub Site Navigation?
There is no security trimming in MegaMenu in Hub Site Navigation, I will say that purpose of Hub site really does not make sense to have MegaMenu security trimmed but at same time it can be debatable.
Audience targeting can be a good thing and it is under work as of May 2019, you can refer here