Yes, you can however I've found in my years of baking that butter gives you a better cookie, and margarine can make the cookies spread too much.