Yes, an employer can require an employee to repay the whole or part of their contractual maternity pay if they do not return to work for a minimum period after their maternity leave has ended. To avoid any mis-understandings, it would need to have been specified in their contract of employment, your Maternity Policy and also clearly stated in their letter confirming their maternity leave start and end dates.
However, the employer cannot require the employee to repay the part of their pay that relates to statutory maternity pay or pension contributions.
The requirement to repay must have been either agreed in writing in advance or included as a clawback clause in the employee’s contract of employment. It is good practice for the employer to draw the employee’s attention to this clawback condition in writing, prior to the commencement of maternity leave, such as in their maternity leave letter.
The employer should consider allowing the employee to repay the contractual maternity pay in a series of agreed instalments if repayment of one lump sum would cause them financial difficulty.
As with any potential discrimination, its best to seek HR advice before responding to a request of this nature.