nbdkit memory 10G --filter=error error-rate=1%
... and then nbd-loop-mount that as a block device and create your filesystem on top.Notes:
We're working on making a ublk interface to nbdkit plugins so the loop mount wouldn't be needed.
There are actually better ways to use the error filter, such as triggering it from a file, see the manual: https://www.libguestfs.org/nbdkit-error-filter.1.html
It's an interesting idea to have an "evil" filter that flips bits at random. I might write that!