There is no builtin feature to do this. But with some scripting it should not be too difficult.
First set a variable in your configuration file for the output(s) and reference it in your workspace
definitions:
set $OUTPUT1 LVDS
set $OUTPUT2 VGA1
workspace 1 output $OUTPUT1
workspace 5 output $OUTPUT2
Then you need a script that changes the variable definitions for you and reloads the configuration
#!/bin/bash
OUT2=$(xrandr | awk '/(VGA1|DP1)/ connected/{print $1}')
OUT2=${OUT2:-LVDS}
sed 's/^set\s\s*$OUTPUT2\s.*/set $OUTPUT2 '$OUT2'/' -i "${HOME}/.i3/config"
i3-msg reload
Now you can set a keybinding for this script.
WARNING: UNTESTED
You could even run this script directly from your configuration file
exec --no-startup-id /path/to/outputcheck.sh
As exec
statements are not executed when reloading the configuration it should not lead to an endless loop. I am assuming that the statements are also only run after i3 has fully parsed the configuration file (for the first time) and reloading can thus be done without risk, but I am not sure.