Here’s a little AppleScript I wrote that moves the dock to the right if my MacBook is the only display and to the bottom if it’s not.

A screenshot of an AppleScript Script Editor window with the code in it