GNU `sed` has a `-z` option that allows to use the syntax the OP attempted to apply. ([man page](http://manpages.ubuntu.com/manpages/bionic/man1/sed.1.html))

**Example:**

```
$ 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
```
----
_Credits:_ @stéphane-chazelas _mentioned this already in a comment above._