Can class D fire extinguishers be used for other fire types than metal fires? Burning metals like sodium should not be extinguished with standard fire extinguishers, but they require either sand or a special class D fire extinguisher. 

Now, if there is a fire in the lab and the closest fire extinguisher is one of those class D extinguishers meant for metal fires, can those be used for other types of fires?

The main case where there might not be enough time to get specific equipment is probably when people are on fire. Can a class D extinguisher be used in this case, if it's the closest available one?
Unfortunately, as far as I can tell, specific class D fire extinguishers aren't even suitable for all types of class D fire, much less other types of fire.

The copper powder variety in particular has limited effectiveness against fires that aren't lithium-based, and the thermoplastic additives in the sodium chloride-based extinguishers may also catch fire.

Dry sodium carbonate-based class D extinguishers should be generally effective but suboptimal against many types of fire, but I'd say in general, even if you have to go a little further, you should go for the proper sort of extinguisher to minimise accidental horrible disasters.