If the spouse of the US president filed for divorce, would
a) the President have any claim of immunity from any litigation that
followed (e.g. the division of assets in the matrimonial pot, child
custody etc.),
The President could claim it, but the President wouldn't win.
Notably, a number of state governors and mayors have divorced while in office, and other foreign heads of state have been divorced while in office.
For example, a U.K. court recently handled the divorce of a UAE monarch (over his objections to jurisdiction on sovereign immunity grounds), applying the same common law principles of head of state and sovereign immunities that exist in U.S. law and concluded that it had the authority to move forward with the case.
Also, any Presidential divorce would take place in state court, not in federal court. Federal courts do not have subject-matter jurisdiction over divorce and custody cases (under the "domestic relations exception" to federal jurisdiction), so the civil action could not be removed to federal court, unlike federal criminal cases involving the official duties of the President and unlike civil cases over which the federal courts have jurisdiction.
b) would all the proceedings be fully held in private,
This would be in the reasonable discretion of the judge. It would not be a matter of right, but it is quite plausible that a judge might close the proceedings, especially if minor children were involved.
c) could the President themselves be compelled to take the stand and
Yes.
A party to a lawsuit may always be compelled to take the stand, at least if no other person can provide a full substitute for the party's testimony.
In ordinary civil lawsuits against the President, a President is usually compelled to testify only if an underling involved in the same matter cannot provide equivalent testimony. In many civil cases naming the President in his official capacity, the President has no personal knowledge of the facts and so can't be compelled to testify. But that would rarely be true in a divorce case, and would never be true in a divorce case where custody was an issue.
This said, a state divorce court judge would almost certainly be very deferential to the scheduling concerns of the President for that testimony, and might allow that testimony to be provided remotely via videoconference so as to minimize the interruption this would pose to affairs of state and to address the security concerns of the Secret Service (i.e. the President's official bodyguards).
d) what would happen if the President refused to do so?
The judge could hold the President in contempt of court, which is punishable by fines and/or incarceration.
But a more likely outcome, tailored to minimize interference with government business, is that the Court would sanction a President who defied an order to testify by assuming as a matter of law that any testimony from the President would have been unfavorable to the President and make a conclusive adverse inference on the evidentiary issues about which the President was asked to testify against the President.