529 withdrawal after graduation for undgrad tuition

Yes - same calendar year is fine, just can’t exceed the applicable 2023 fees/expenses.

If after the expected 2023 expenses there are still funds, then its best to take those in December 2022 to apply against 2022 costs.