If you want to do true arbitrary palettes you also need to do projection of the unbound Oklab space onto the convex hull of the palette points. This is a tricky thing to get right, but I've found that the Oklab author's published gamut clamping for sRGB also translate well to arbitrary convex hulls.
If anyone's curious I've implemented this here: https://github.com/DDoS/Cadre/blob/main/encre/core/src/dithe... I use it to map images from their source colour space to the lower gamut palettes of E Ink colour displays.