If you're comfortable with the side effect of making the assignment conditional on tempfile not previously having a nonempty value, this is straightforward via the ${var:=value} expansion:
tempfile
${var:=value}
cat "$HOME/.bash_history" >"${tempfile:=$(mktemp)}"
I guess there is more than one way to do it. I found following to be working for me:
cat myfile.txt > $(echo "$(mktemp)")
Also don't forget about tee:
tee
cat myfile.txt | tee "$(mktemp)" > /dev/null
cat myfile.txt | f=`mktemp` && cat > "${f}"