How to remove the trailing newline (`LF`) character (the terminal newline, the EOF newline) from a text file using `sed`?

sed -z -i 's/\n$//' <file>