To store the heapdump files in a custom directory, use --diagnostic-dir= flag while running the node process.
--diagnostic-dir=
Refererence - https://github.com/nodejs/node/pull/47854