A solution I have found is to add the same layout twice (i.e. make a copy of the layout in ~/Library/Keyboard Layouts/
). This somehow breaks the auto-switching and/or switch prevention, making it keep the layout I want.
The only downside is that the layout shows up "twice" in the drop-down menu in the menu-bar (both have ticks too). Switching between layouts using the OS shortcut is not impacted however because both layouts are treated as one.
On another machine, I've somehow gotten it to bug out so far that I don't need the second layout anymore. I don't know how but you could try removing the second layout again after some messing around and it might continue to work like that. (Please LMK if you find out know what triggers this.)