In the file themes/[your_theme]/template.php, try to create a function to override it. For naming function, it is explained here
By the way, you should never override a function into its module. You have to create your custom module to override it. It's easier to keep your custom code if you need to update Megamenu for example.