Though Vim is primarily designed for dealing with text files, it can be used to read, view and write binary files with the help of external tools. I like the use of the xxd tool for this.
$ vim foobar.bin :set binary
$ vim -b foobar.bin
To edit the binary file, edit the characters on the left side of the hex dump.
To write the hex dump of the binary file:
Tried with: Vim 8.1 and Ubuntu 20.04