Switch to a specific input source in OS X in Catalina with AppleScript
Unfortunately things have changed in macOS Catalina and you''ll have to activate that menu in a different manner.

The following example AppleScript code, shown further below, works for me in macOS Catalina, however as I was testing in a virtual machine I do not know if the time lag in the running of the code, between clicking the target menu and the subsequent code, is inherent of an issue in the virtual machine or it will be the same on a physical machine.

I do not have German LaTeX2 so I used German instead, although for convenience I have replaced it in the code after testing.

The usual caveats apply for the use of this in: System Preferences > Security &amp; Privacy > Privacy > Accessibility

Example AppleScript code: 

tell application "System Events" to ¬
    tell application process "TextInputMenuAgent" to ¬
        tell menu bar item 1 of menu bar 2
            click
            click menu item "German LaTeX2" of menu 1
        end tell


This does the same thing in a different manner, and one of these ways may be faster.

tell application "System Events" to ¬
    tell application process "TextInputMenuAgent" to ¬
        click menu bar item 1 of menu bar 2

tell application "System Events"
    keystroke "g"
    key code 36
end tell


To use the example AppleScript code in a handler:

changeKeyboardLayout("German LaTeX2")

on changeKeyboardLayout(layoutName)
    tell application "System Events" to ¬
        tell application process "TextInputMenuAgent" to ¬
            tell menu bar item 1 of menu bar 2
                click
                click menu item layoutName of menu 1
            end tell
end changeKeyboardLayout


Or the second version of the code:

changeKeyboardLayout("German LaTeX2")

on changeKeyboardLayout(layoutName)
    tell application "System Events" to ¬
        tell application process "TextInputMenuAgent" to ¬
            click menu bar item 1 of menu bar 2
    tell application "System Events"
        keystroke (first text item of layoutName)
        key code 36
    end tell
end changeKeyboardLayout




Note: The example AppleScript code is just that and does not contain any error handling as may be appropriate. The onus is upon the user to add any error handling as may be appropriate, needed or wanted. Have a look at the try statement and error statement in the AppleScript Language Guide. See also, Working with Errors.