sed has a
-z option that allows to use the syntax the OP attempted to apply. (man page)
$ cat alpha.txt This is a test Please do not be alarmed
$ sed -z 's/a test\nPlease do not\nbe/not a test\nBe/' -i alpha.txt
$ cat alpha.txt This is not a test Be alarmed
Be aware: If you use
$ they now match the beginning and end of lines delimited with a NUL character (not
Credits: @stéphane-chazelas mentioned this already in a comment above.