shred, from the GNU coreutils package, to securely overwrite data in-place when removing files. What is the equivalent on BSD systems (and specifically on macOS)?
The answer that qorg11 gave is the technically accurate answer to your question (so go and upvote it!).
The reality is that
shred is useless. All BSDs, as well as Linux, have modern file systems, where "overwrite a file to actually overwrite the bytes on the storage medium" simply does not happen because it's not how the structure of a file system looks like and how the storage device works.
What shred does is take a file and overwrite its contents with zeros. Great, but many modern filesystems are "copy on write" (i.e., when you change something in a file, you don't modify the same blocks on the storage device, you make a modified copy of the affected block). Apple's APFS is definitely one of these file systems.
Some file systems have "sparsity detection": you write all-zeros, so the file system doesn't write these zeros to disk but just denotes a hole in the file.
All SSDs have write wear balancing: you're really not protecting against an attacker that can access the raw data as stored on the memory chips because all writes to the system are essentially copy-on-writes to evenly distribute the load of writing data across the medium (writing the same cell often leads to ageing and increased error probability; since an SSD has uniform access latency, wildly distributing logical blocks across the physical medium has no downside). On the flip side, modern file system drivers support the TRIM operation (often called "discard"), which signals to the SSD that the data can be zeroed, and the SSD will then quite likely not even read the zeros if being asked for that logical block.
So, as qorg11 says,
shred is the equivalent of
shred, even on non-GNU systems, if you install GNU coreutils, but an
rm works just as well, in reality.
rm itself has the -P flag.
OS X man page documents it as:
-P Overwrite regular files before deleting them. Files are overwritten three times, first with the byte pattern 0xff, then 0x00, and then 0xff again, before they are deleted.
OpenBSD man page:
-P Attempt to overwrite regular writable files before deleting them. Files are overwritten once with a random pattern. Files with multiple links will be unlinked but not overwritten.`
On FreeBSD however it does nothing, but the flag was kept for compatability.
The BUGS section of the OpenBSD man page warns about its limitations: http://man.openbsd.org/rm#BUGS
The -P option assumes that both the underlying file system and storage medium write in place. This is true for the FFS and MS-DOS file systems and magnetic hard disks, but not true for most flash storage.
These also applies to shred.