Add action hook into wp_localize_script

Everything is working as expected. The problem is that your hook is rendering content to the page and you would like to pass that output to the javascript variable included in the JS output. You need to capture the hook output into a variable then add to $data.

// buffer output
ob_start();

   // run hook
   do_action('myplugin_after_hook');

// get the output buffer into a variable
$ng_slicknav_hook = ob_get_clean();

// add to data
$data = array(

    'ng_slicknav' => array(
        'ng_slicksearch'           => home_url("https://wordpress.stackexchange.com/"),
        'ng_slicknav_closedsymbol' => esc_html($options[ 'ng_slicknav_closedsymbol' ]),
        'ng_slicknav_hook'         => $ng_slicknav_hook,
    ),

);

It will most likely need to be escaped but I’ll leave that to whatever content you’re creating.