I have pre-settled status and am going abroad soon, but my passport expires within 6 months. Does it need to have six months validity to be able to come back to the UK?

The rule, about needing 6 months' validity on a passport before expiry, applies to people travelling with non-EU passports to the EU.

When travelling to the UK, people are required to have passports (or national identity card) valid for the length of their stay (see https://www.gov.uk/uk-border-control/before-you-leave-for-the-uk).

In the case of people who have immigration status in the UK, the "length of stay" doesn't apply. So as long as your passport (or national identity card) is valid when you come back to the UK, there should be no problem.