How to get custom page template being edited in gutenberg editor

You can use this code once set page template for specific post. If the template isn’t set, you cant enqueue your script.

if ( $post->_wp_page_template === 'sky-template.php' ) {
        wp_enqueue_script();
}

Remember to replace sky-template.php with your template file name.

Edit:

You can get some help from this question.
_wp_page_template to dynamically use template