Because there is actually no entitlement to maternity pay (just the requirement that they leave your job - or an equivalent - available for 12 months for you) each company is different.

I would be asking the question what happens if you decide not to come back? then they have to tell you what they would do. If they would make you pay it back or whatever.

If you resign when you are planning on finishing work then as I see it you aren't entitled to any maternity pay as you aren't an employee but a boss may cut a deal with you if you give them notice beforehand as it means that they don't have to muck about with staffing if they know you aren't coming back. If it were me I would find out their policy and then decide.

I used to work for a company that paid 4 weeks but it was 2 when you left and 2 when you came back and another that paid 12 weeks but if you didn't return to full tie work within 2 years you had to pay 10 weeks back.

HTH