Switching appearance means a trip into System Settings. AppleScript can flip it from the terminal, which also makes it easy to put behind a shortcut.
System Events exposes the appearance setting. This toggles it:
osascript -e 'tell application "System Events" to tell appearance preferences to set dark mode to not dark mode'
To read the current state, for a script that should act differently in the dark:
osascript -e 'tell application "System Events" to tell appearance preferences to get dark mode'
It answers true or false. Setting it to true or false instead of not dark mode gives you fixed commands, one for each mode.
I’d keep the toggle as a shell alias. You can also paste the AppleScript part into a Run AppleScript action in Shortcuts and give that a keyboard shortcut.
The first time, macOS asks whether Terminal may control System Events. Allow it, or the command fails with a not authorised error. You can change that later under Privacy & Security, Automation.
Further reading: osascript man page (macOS), Mac Automation Scripting Guide (Apple)