How can I make macOS respect HOSTALIASES environment variable?
The man page that you referenced is very old (ancient) - it's from 1995.  Looking at the man page for gethostbyname on a machine running El Capitan (2006), that reference is no longer there meaning it's a very good indication that what you are looking for has been deprecated.