Keeping the environment via `sudo -E` is slightly trickier.
If you need that for a fixed set of commands you can enable keeping the environment for those explicitly via the configuration file using the `keepenv` option. You can also set specific variables for specific commands,
But you would need to use a workaround if you want to keep the environment for a command without always adding that to the configuration, one way would to add a wrapper executable and add a permanent rule for that, e.g. something like the following should work:
# reuse the `env` tool, but use an explicit symlink to have clear boundaries
ln -s /bin/env /bin/keep-env
# add rule for keep-env to doas cfg, replace USER with your user name, or prefix with : for a group
echo 'permit persist keepenv USER cmd /bin/keep-env' | tee -a /etc/doas.conf
# run command
doas keep-env THE-ACTUAL-COMMAND
Disclaimer, not deeply tested and there might be even better options, but FWIW, this workaround is at least quite simple in principle.