Not actually a one-liner, but you could do this with one invocation of sed:
sed -e '
/pat/{s//repl/g;h;}
$!b
G
s/\n..*//;t
s/$/repl/
' yourfile
N.B.: I've deliberateley used pat and repl for pattern and replacement respectively, and not the shell variables as you've done. Basically for 2 main reasons, they would get in the way of the sed code flow + for correctness we need to quote both, and differently at that, to make them work. That job I leave it to you.
Flow: Say, the file never had a /pat/ then all lines are taken to stdout by the $!b command and the last line when appended by G just sees an empty hold
so the t is not taken and we have an append operation.
When we see a /pat/ line, then it is s///-ed and hold area is marked. if it's not the last line, we simply break out to stdout. For eof, we do a check of hold and since it's non-empty(assuming repl is NONEMPTY, the test path would be taken after removing the hold from the pattern space.
Perl affords the clarity to match the intent word-for-word in the code:
perl -lne '$a += s/pat/repl/g,print}{print q[repl] unless $a'
To be read as: The variable $a serves as the counter for the number of substitutions. At the end, we would append to file when no subs were made earlier.
And as for supplying the pattern/replacement info via variables, we can do it:
WHAT_I_WANT='my line of text = something'
WHAT_TO_REPLACE='my line of text = .*'
FILE_TO_EDIT=conf_file.conf
perl -li -sn -e '
$a += s/$pat/$repl/g,print}{print $repl unless $a
' -- -pat="$WHAT_I_WANT" -repl="$WHAT_TO_REPLACE" -- "$FILE_TO_EDIT"
sedcommand if you want to change every occurrence of that text. Sorry for posting but I don't have yet enough of the points to comment.