Is there any way to change the mac dock's position with a keyboard shortcut?
This AppleScript code works for me using the latest version of macOS Mojave.

tell application "System Events" to tell dock preferences
    if screen edge is bottom then
        set screen edge to left
    else if screen edge is left then
        set screen edge to bottom
    end if
end tell


In Automator, create a new Service or Quick Action and add a run AppleScript action to that workflow, adding the above AppleScript code.  Then in System Preferences you can create a keyboard shortcut for that new service.