Beryl with DNS over TLS, but only active if successful internet connection is made?

On Beryl connected to a hotel wifi, no encryption but one has to enter a password on the captive portal. The hotel wifi then presumably stores the MAC address of the router and after entering password the user can use it.

Is it possible to have DNS over TLS active but only when a successful internet connection is made?
If not internet connection is done, DNS over TLS should be inactive to get to hotel captive portal. Would something like this be possible to set up?

This is difficult.

Before we developed a program, which will detect if there is a portal. When a portal is detected, it will disable vpn and dns encryption etc. and make sure the portal page can pop up.

But eventually didn’t use that because of the efficiency.