You can put arbitrary entries into a PNG image palette, but it won't help you for all the reasons you have been given in the comments.
#!/usr/bin/env python3
from PIL import Image
import numpy as np
# Open your image and ensure it is in Palette mode
im = Image.open('P4mFP.png').convert('P')
# Check first 2 RGB palette entries are black and white
print(im.getpalette()[:6]) # prints [0, 0, 0, 255, 255, 255]
# Stuff in new palette with 2 original values plus 254 other, random RGB values
im.putpalette([0, 0, 0, 255, 255, 255] + list(np.random.randint(0,256,254*3)))
# Save the new image
im.save('result.png')

Check the palette with ImageMagick:
identify -verbose result.png
Image:
Filename: result.png
Permissions: rw-r--r--
Format: PNG (Portable Network Graphics)
Mime type: image/png
Class: PseudoClass
Geometry: 1920x1080+0+0
Units: Undefined
Colorspace: sRGB
Type: Bilevel
Base type: Palette
Endianness: Undefined
Depth: 8-bit
...
...
Colors: 2
Histogram:
2005891: (0,0,0) #000000 black
67709: (255,255,255) #FFFFFF white
Colormap entries: 256
Colormap:
0: (0,0,0,1) #000000FF black
1: (255,255,255,1) #FFFFFFFF white
2: (102,218,69,1) #66DA45FF srgba(102,218,69,1)
3: (76,252,109,1) #4CFC6DFF srgba(76,252,109,1)
4: (141,189,112,1) #8DBD70FF srgba(141,189,112,1)
5: (98,185,56,1) #62B938FF srgba(98,185,56,1)
...
...
252: (44,1,152,1) #2C0198FF srgba(44,1,152,1)
253: (244,134,106,1) #F4866AFF srgba(244,134,106,1)
254: (254,129,16,1) #FE8110FF srgba(254,129,16,1)
255: (41,166,211,1) #29A6D3FF srgba(41,166,211,1)