There is an excellent utility (although retired it still works): https://github.com/google/rekall/tree/master/tools/osx/MacPmem
MacPmem enables read/write access to physical memory. It simultaneously exposes a wealth of useful information about the operating system and hardware it's running on through an informational device and sysctl interface.
It exposes two devices:
/dev/pmem # Physical memory read access (can be built with write support).
/dev/pmem_info # Informational dump.