Yes, you can use margarine as a substitute for butter in this recipe. However, keep in mind that it may slightly alter the taste and texture of the cupcakes.