Modify available templates (in dropdown)

The list of available templates is generated by get_page_templates. By the end of this function you see a filter that allows you to modify the output. You can use that to change it under certain conditions like this:

add_filter ('theme_page_templates','wpse302574_conditional_templates', 10, 4);

function wpse302574_conditional_templates ($post_templates, $this, $post, $post_type) {
  $parent_id = wp_get_post_parent_id ($post->ID);
  if (get_page_template_slug ($parent_id) == 'slug_of_your_parent_template') {
    // remove unwanted templates from $post_templates
    }
  return $post_templates;
  }

( I didn’t test this code, some debugging may be necessary )

error code: 523