In this case replacement is passed in $1. Will replace TOKEN_NAME in given /path/to/my/templatefile.txt.
The magic is sed --regexp-extended 's/[\/&]/\\&/g' - ensures replace value is not tripped up in call to sed.
#!/bin/bash -e
tokenReplace=$1
cat /path/to/my/templatefile.txt | \
sed --regexp-extended "s/TOKEN_NAME/$(echo "$tokenReplace" | sed --regexp-extended 's/[\/&]/\\&/g')/" \
>/path/to/output.txt