If you search for "aem dialog show hide" you will find a lot of examples on the web. One of them that looks a bit old though but might still be working is this one:
https://experienceleaguecommunities.adobe.com/t5/adobe-experience-manager-blogs/show-hide-cq-dialog-fields-based-on-drop-down-selecti...