On Linux and with shells that implement here-documents with writable temporary files (like zsh or bash doesversions prior to 5.1 do), you can do:
{
out=$(
chmod u+w /dev/fd/3 && # needed for bash5+bash5.0
ls /dev/null /x 2> /dev/fd/3
)
status=$?
err=$(cat<&3)
} 3<<EOF
EOF
printf '%s=<%s>\n' out "$out" err "$err" status "$status"