Read single post template in plugin

function custom_book_single_template($single_template) {
    global $post;

    // Check if the post type is 'book'
    if ($post->post_type == 'book') {
        // Assuming your template file is 'custom-book-template.php' located in 'templates' folder inside the plugin directory
        $single_template = plugin_dir_path( __FILE__ ) . 'templates/custom-book-template.php';
    }
    return $single_template;
}
add_filter('single_template', 'custom_book_single_template');