I'll warrant the guess that you will get pretty close to your goal by escaping slashes and backslashes with a prepended backslash each. AFAIK that can't be done in bash in a single step, so you can either write a function to make it readable, or enjoy your trip to the leaning toothpick forest:
$ echo %foo% > test
$ replacement="//this//is//a\\\\//test"
$ echo $replacement
//this//is//a\\//test
$ stage1=${replacement//\\/\\\\}
$ echo $stage1
//this//is//a\\\\//test
$ stage2=${stage1//\//\\\/}
$ echo $stage2
\/\/this\/\/is\/\/a\\\\\/\/test
$ ed -s test <<< g/.*foo.*/s/foo/$stage2/p
%//this//is//a\\//test%
Newlines remain a problem, but then you don't want to keep them in bash environment variables anyway since whitespace isnt' very stable there.