Conditionally check if page is using template from plugin directory

If I understand it correctly, you would like to check your template right before loading.

I think the hook template_include is the best place you could do it.
Because this is the last place to load the template in loading procedure.

Regardless plugin or themes functions.php, it will also work.

The following is proved to be working in theme functions.php

add_filter( 'template_include', 'q364016_check_template' );
function q364016_check_template( $template ) {
    // your code

    return $template;
}

error code: 523