Can one contribute their max annual limit to their 401K in 2023 to defer capital gain liability from the sale of an investment property in 2023? Reducing tax liability?

The property was not originally purchased with funds from a 401k/retirement account.