Yes, you can. In fact, ghee is a much better option than butter due to the healthy vitamins and fats it contains. For baking purposes like greasing the cake tin or mixing in the batter, ghee will be an excellent replacement.