529 accounts are similar to Roth IRAs, in that the contributions are after-tax. Only the investment gains are sheltered from taxes.
Thus, I see no benefit to depositing money in a 529 and then immediately withdrawing it to pay you spouse's SL debt.
There is really no such thing as an "early" withdrawal from a 529 plan. As long as the account beneficiary has qualified education expenses, it doesn't matter if the account in question has been open for 18 years or six months.
And, since you've already paid income taxes on the money you contribute to a 529 plan, you are free to withdraw your original contributions at any time for any reason.
However, if you withdraw any investment gains from a 529 account before the account beneficiary incurs any qualifying expenses, or for non-qualified reasons, the IRS can assess a 10% early withdrawal penalty.
Having said that...
Since the passing of the SECURE Act, 529 plan holders are able to withdraw up to $10,000 tax-free to put toward their own student loan debt, or that of their children, grandchildren, or spouses.
(That includes any investment gains.)