As a simple example, H2O molecules are identical, but water can have three different forms (liquid, vapour, ice.) What about more complex matters, like drugs? Can they have different forms which work differently?
Many drugs come in more than one form -- or formulation, I should say. For example, it's common for a drug to come in an oral formulation and an injectable formulation: same chemical, different formulation with different usages. There are many dosage forms.
Do they work differently? Yes and no. Typically, the drug is going to exert the same general effects regardless of delivery method, but those effects are going to occur more rapidly if given intravenously than orally, for example.
A good example is menoxidil.
Minoxidil is a vasodilator that relaxes (widens) blood vessels and improves blood flow.
This effect gives minoxidil two very different uses: the first is as a pill that reduces high blood pressure, and the second is as a topical ointment that can regrow hair on the scalp. The mechanism of action is the same for both purposes (increasing blood flow), but the effect is very different given the formulation. A pill affects the body as a whole and so reduces blood pressure, but the topical ointment affects only a small area of scalp so encourages hair growth in that area without having an effect on blood pressure.
Similar examples abound.
In addition to Carey's excellent answer, many drugs also exhibit polymorphism, the ability to form different crystal structures (think coal, graphite, and diamond, which are all different crystal structures of carbon), solvates, and hydrates (H2O added). Each polymorph will almost certainly have different chemical properties such as solubility, melting and boiling points, etc. This article from American Chemical Society describes the problems synthesizing a drug called axitinib, as it can form sixty-six different polymorphs. It also describes a drug, raltegravir that Merck is exploring the different properties of with those different forms. Also, this article from Wikipedia (please note here I am referencing Wikipedia for chemical, not medical, information) describes some excellent issues with polymorphs of Zantac, among others.