How can I make macOS respect HOSTALIASES environment variable?

According to the Apple developer documentation, setting HOSTALIASES will make a process look in that file for hostnames instead of /etc/hosts.

However when I tested this with ping and a replacement hostfile, the replacement never got used, only /etc/hosts (according to fs_usage) – I have also seen similar complaints online.

Is there a way to get a process to respect HOSTALIASES or otherwise use a different hosts file?