How to set keyboard layout in the terminal?

Ok, so it seems to be an upstream issue. That is Microsoft, in this case. Tracked in Keyboard layout messed up for KBD_PORTUGUESE_BRAZILIAN_ABNT2. · Issue #27 · microsoft/wslg · GitHub

Workaround: export WAYLAND_DISPLAY="wayland-1"