Is it dangerous/harmful to increase the voltage supplied to a 12v electromagnet?
Since it is a door lock, it will be on all the time, and likely unsupervised.  If the magnet were being used only for an intermittent function, such as picking up nails, then I'd say that just giving it shorter on-periods might be enough to compensate for the extra heat.  Given its use as a door lock, I'd have to say that I absolutely would not take the chance of using 20 volts when it's specified for 12 volts.