You certainly could, but extracts vary so much in terms of potency. It would be hard to know exactly how much to use. You might use just a tiny amount in the cake layer and then focus the lavender flavor in the buttercream, where you could add it in a little at a time and taste it as you go.