I have been dealing with the same issue and found the solution on https://furnacecreek.org/blog/2024-12-07-centering-nswindows-with-nshostingcontrollers-on-sequoia
Here is the OP's sample code with the one line fix added:
let contentView = WelcomeView()
let hostingVC = NSHostingController(rootView: contentView)
onboardWindow?.contentViewController = hostingVC
onboardWindow?.updateConstraintsIfNeeded() // fixes zero size issue