I would like to access my ESP8266-12 (NodeMCU) in the same way.
I have created several projects, and when connecting to my WiFi, I use the following...
WiFi.hostname(our_name); // tell the router who we are
WiFi.begin(ssid, password); // start the connection
Is defined as a char somewhere.
I do see the proper string in the list of computers on my router, but I cannot access the web server (in the ESP) by that name. I must enter the IP address.
Part of the problem may be that I don't totally understand how the local DNS translation works.
Can someone help me to figure this out?