How To Create A Custom Taxonomy 404 Page

You can filter any type of template to override the template hierarchy. In this case the filter is 404_template.

We’ll check if the location query var is set, meaning the URL matched the pattern of a location request, but the result was a 404. In that case, we’ll load the 404-taxonomy-location.php template.

function wpd_custom_tax_404( $templates ){
    if( '' !== get_query_var( 'location' ) ){
        $templates = locate_template( '404-taxonomy-location.php', false );
    }
    return $templates;
}
add_filter( '404_template', 'wpd_custom_tax_404' );

This code should go in your (child) theme’s functions.php file.