I just want to throw my 2 cents in. What you are going to do is legal and allowable. But from a professional standpoint, it sucks. Your company is going to have to find someone to cover you for the entire maternity leave, and then once you quit, they are going to have to rehire anyway. I think this is taking advantage of your company's maternity leave policy. But if you are morally okay with this, then whatever floats your boat. I personally think it's very unprofessional.
Case in point - we had an employee who was essential. She went out on maternity leave. We never did find an adequate person to cover, so the entire team struggled continuously for 8 weeks. She then came back and quit. We could have hired from the beginning and skipped all of that nonsense. We felt tricked and she was viewed to have taken advantage of the maternity leave system.
You obviously have to be physically at work for the two weeks to give a real "two weeks notice". Otherwise, they can make you non-rehireable for reason of lack of notice (some go as far as to call it job abandonment, which can make it very difficult to get another job in the future). You have to work more than the day or two - you have to be there for that entire two weeks. You can't give the notice while you are on maternity leave because you have to be back at work after leave to avoid having to pay back for the leave time. So you should go in once your leave ends, give your notice that day, and then work until your notice period is up.
Again though, what you plan to do is legal.