This is an ok solution, but I'd like to do something more elegant. That simply run the scripts and then assigned them to keyboard shortcuts. This is because they rely on opening the System Preferences app and navigating through the menus. That's why I wrote two AppleScripts to switch the layouts (included below).
I also don't like holding down the fn key. I like the default Mac touchbar layout for everyday use, but I prefer the F1-F12 keys at my fingertips when programming.