How do I hide the SSID of an Android phone? I sometimes use my phone as an ad-hoc WiFi network, however there is no option in the settings to hide its SSID. How can I achieve this?
You cannot hide AP SSID (stop SSID broadcasting or beaconing) through Android API.

SSID hiding depends on the kernel/WiFi-driver that you have on your phone. Only a few drivers (devices) support this feature. Also, a few drivers support monitor mode. Vendor-drivers have closed source which makes it difficult to add these features to them. See bcmon project for example.

Android API allows you to connect to the network with specific SSID (it may be hidden) programmatically. You should know network SSID and password (see this link about WifiConfiguration class and hiddenSSID, this link about WifiManager class, and these Stack Overflow answers: programmatically create WiFi Configurations, connect to a specific WiFi network).