You should not believe them if they tell you it cannot be done. You should believe them, however, if they tell you it's not easy.
sed '\|*/|!{ s|/\*|\n&| #if ! */ ...
repl 1st \|/\*|!{ #and if* !w/ \n/* ...
h; s|foo|bar|g;/\n/!b s|foo|bar|g;b #repl#hold; repl all foo w/ bar, branch out...
}; s||\n|;h bar; #elseifif ! */ and /* repl 1st /* w/ \n;\n savebranch
s|foo|bar|g;G #replG; all foo w/ bar; Get save
s|\n.*\n||;:n s|\n.*\n|/*|;:n;n #Get; #removeclear difference; :new label;label
new line
n; \|*/|!bn;s|^|\n/*| #if ! new#new lineline; if ! */; branch new label
};s|*/|\n&|g #repl all */ w/ \n*/
s|foo|&\nbar|g;:r #repl all foo w/ foo\nbar
s|\(/\*[^\n]*\)\nbar|\1|g;tr #repl all /*[^\n]*\nbar w/ foo
s|foo\n\(b\)|\1|g #repl all foo\nbar w/ bar
s|^\n/.||;s|\n||g #clear any \n inserts
' <<\INPUT
asfoo /* asdfooasdfoo
asdfasdfoo
asdfasdfoo
foo */foo /*foo*/ foo
/*.
foo*/
foo
hello
INPUT
###OUTPUT
asbar /* asdfooasdfoo
asdfasdfoo
asdfasdfoo
foo */bar /*foo*/ bar
/*.
foo*/
bar
hello