macOS sometimes can't connect to WiFi hotspot that's really working perfectly
It happened again twice since I posted this, and I think I found something that seems to work. On the terminal, I do:

networksetup -setairportpower en0 off

networksetup -setairportpower en0 on

/System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport --scan


(that last command shows a list of available networks with their SSID)

networksetup -setairportnetwork en0 MyWifiSSID MyWifiPassword


Both times this made my connection work again.

Haven't tried Monomeeth's solution yet, but as it involves more manual interaction and rebooting my laptop, I hope the above 'on the fly' method will suffice.