Early stage tumours had relatively low levels of DNA methylation, while advanced cancers (those that had spread) had much higher levels, suggesting the gene was more tightly shut down.
Measuring levels of methylated TFP12 in DNA in the blood could help doctors work out whether the disease has spread and what treatments may be needed.
Dr Tim Crook, study author and a consultant medical oncologist based at the University of Dundee, said: "Once melanoma starts to spread it becomes far more difficult to treat. But actually detecting whether or not it has started to spread is also challenging.
"By using a blood test, we have the basis of a simple and accurate way of discovering how advanced the disease is, as well as an early warning sign of whether it has started to spread....
"There's increasing evidence that the latest treatments are more effective in these early stages and, if we can identify patients whose cancer has only just started to spread, this would significantly improve the chances of beating the disease."
The same Dundee researchers have identified another potential biomarker - NT5E.
This gene appears to become methylated and switched off as melanoma first develops. But if NT5E becomes unmethylated again, the gene is reactivated and helps the disease to spread more aggressively.
The researchers suggest that NT5E could be a possible target for the development of new treatments to tackle melanoma, particularly for aggressive cancers that have spread to the brain, lungs and other organs.
Professor Charlotte Proby, a Cancer Research UK dermatologist based at the University of Dundee, said: "Using blood tests to assess the landscape of our DNA is a simple way to learn more about what's going on under the skin. The switching on and off of certain genes seems to affect when, where and why the melanoma spreads.
"Our goal is to develop a panel of similar biomarkers that will help us to accurately detect those patients needing extra treatment to fight their melanoma.
- PA