This is a very specific topic, but it was hard to find information about it online, so I’ll post my findings here.
If you want to force a certain color palette on your image in Photoshop you can choose
Image –> Mode –> Indexed Color.
A window will pop up where you can choose a palette. If you want to create your own palette in which you select all the colors, you can do this:
Set the palette to “custom”. A color table window will open. You can delete existing colors by ctrl-clicking on them. You can add more colors by clicking an empty color slot and picking a color for it.
Here’s a quick gif-like video of creating custom color tables (ACT-files) in Photoshop and saving them for later use: