Yes, this method will work. I’ve done it before when buying peeled garlic.  If using peeled garlic, the best cooking method is thoroughly coat the garlic cloves with olive oil and also add a bit more olive oil over the tops of the cloves of garlic in the baking dish.  Cover it tightly to keep the moisture inside and cook in the oven at 350° F for 30 minutes stirring occasionally and rewrapping tightly. The garlic is done when super soft.