Since "lo" is masculine, it doesn't refer to the cake. So it seems better to say "if you do it like that."
If you "make" it like that... no good here?
Also correct to say, "if you do that..."?
Then you probably wouldn't need the word "cosi'".
"If you do so, you burn the cake".
Now this is accepted too.