I am using Micropython on Thonny (version 4.1.6) on Ubuntu 22.04 with a PicoW target.
I wanted to change the hostname, so wrote this code:
import network
import socket
from secret import ssid, password
wlan = network.WLAN(network.STA_IF)
wlan.active(True)
wlan.connect(ssid, password)
wlan.config(hostname="Brian")
print (wlan.config("hostname"))
When this runs, it displays the new hostname.
However, when I check on this via either my router, or nslookup <ipaddress> or host <ipaddress>, I get the same answer - which is e.g. Unknown-<mac address>.
This seemed to be a solution that others found worked, so I wondered what I might be doing wrong.
(As a note, I also tried setting the hostname before connecting, but it had the same result, and elsewhere, I saw the command should be dhcp_hostname=..., but that generated an error.