All land is owned by someone and most places are considered private. So you would have to find out who the owner is and ask permission. If the land is owned by the state, it is probably a state park or state-owned forest. In many states they won't even consider a request to hunt, or detecting is allowed on non-historical sites only.
If land is owned by the Feds, no permission is likely & you many be facing very high fine or imprisonment if you detect there without permission.
If an individual or family owns it, you might be able to get permission. If a town has just a few people left, they might consider themselves owners of all and may say yes, but many are grouchy old people who don't trust strangers and value privacy.
Sometimes small cities that are semi-ghost towns can be a good place to hunt. If you see vacant lots, they could've been bought by the neighbor but in many towns where people abandoned an unsaleable house, the city took over ownership. Could be possible to get permission from city to detect all the vacant lots they own.
If a town is now a county park, rules vary by county.
I hope someone who has had success getting permission for ghost towns will write something here. Best wishes, George (MN)