This is not possible without installing third-party software, since Windows only allows
changing firewall settings for individual applications.
The only way to implement a specific rule like this is to use the “netsh” program on the command-line.
A rule matching these requirements can be created in “Windows Firewall with Advanced Security”, located in the Control Panel.
The firewall rule must be added from within the application that is using that port.