Hook for when a page template is changed

If you want to toggle the editor “on the fly”, you’ll need to revert to a pure JavaScript solution, and only ever “visually” hide it (as opposed to removing it server-side):

function wpse_189693_hide_on_template_toggle() {
    $screen = get_current_screen();
    if ( $screen && $screen->id === 'page' ) :
        ?>

<script>
    jQuery( "#page_template" ).change(
        function() {
            jQuery( "#postdivrich" ).toggle( jQuery( this ).val() === "my-template.php" );
        }
    ).trigger( "change" );
</script>

<?php
    endif;
}

add_action( 'admin_print_footer_scripts', 'wpse_189693_hide_on_template_toggle' );

The reason you can’t keep your hide_editor_function is, whilst this will work to initially hide the editor, once the user saves and reloads the page the editor will no longer be in the source to “toggle”. So it always has to be there, even if it’s just hidden.

error code: 523