You can create new palette using NewPalette function in Imaging.pas (check out other palette functions there like CopyPalette, FindColor, FillCustomPalette, etc.).
After call to NewPalette you can modify palette entries easily, it's just array of RGBA values (Pal[10].R := 255).
Existing image can be mapped to palette using MapImageToPalette function.