man gifsicle / man magick do not have specific sections about how to do this.
gifsicle --batch -O2 example.gif says gifsicle: warning: so many colors that local colormaps were required gifsicle: (You may want to try '--colors 256'.), but with --colors 256 the result example.gif is so corrupted it is almost unviewable (guess is that this uses a fixed set of the world’s most common 256 colors, not the 256 which the source .gif most uses). The size reduction with --colors 256 is from 92megabytes to 32, which is impressive, but unviewable; want to compress/refuse some of those palette bitmaps, but preserve most of the original chromas.
Guess is that numerous steps are required to do this.
man gifsicle has:
--transform-colormap command
Command should be a shell command that reads from standard input
and writes to standard output. Each colormap in the output GIF is
translated into text colormap format (see --use-colormap below)
and piped to the command. The output that command generates (which
should also be in text colormap format) will replace the input
colormap. The replacement doesn't consider color matching, so
pixels that used color slot n in the input will still use color
slot n in the output.
--use-colormap colormap
Change the image to use colormap. Each pixel in the image is
changed to the closest match in colormap (or, if --dither is on,
to a dithered combination of colors in colormap). Colormap can be
web for the 216-color "Web-safe palette"; gray for grayscale; bw
for black-and-white; or the name of a file. That file should
either be a text file (the format is described below) or a GIF
file, whose global colormap will be used. If --colors=N is also
given, an N-sized subset of colormap will be used.
Text colormap files use this format:
; each non-comment line represents one color, "red green blue"
; each component should be between 0 and 255
0 0 0 ; like this
255 255 255
; or use web hex notation
#ffffff ; like this
--use-exact-colormap colormap
Same as --use-colormap, but the output GIF will use colormap as
is, rather than reordering it and dropping unused colors.
man magick has:
-colors value preferred number of colors in the image
-colorspace type alternate image colorspace
...
-quantize colorspace reduce colors in this colorspace
ffmpeg -i "input.mp4" -map 0:v:0 -f image2pipe -vcodec ppm - | convert - -coalesce -colors 256 -unique-colors global_palette.png produces thousands of global_palette-n.png (where n is the frame number of individual images); guess you can use those with convert -remap, but there is no reason to unless you can compress those into one (or a few) maps.