Yes. If you find that your dog is suffering from constipation or hyperacidity, Milk of Magnesia is one of the safest medicines.
If you already have Milk of Magnesia in your medicine cabinet, ask the vet if it will work for your pet dog's particular condition.