Yes, cooking a frozen ham is totally fine, just with a couple of caveats. Think of your oven as an emergency defrosting device. The ham is going to need extra time to both thaw and cook properly.