The easy solution is to use different SSID for 2.4GHz and 5GHz, and then connect to the 5GHz one.
On RPiOS I forced 5GHz by specifying the mac address of the 5GHz interface of router (with bssid=<mac addr>) in wpa_supplicant.conf
But my LE Pi is wired so I've not investigated how that handles wifi config.