Well, that depends on the engine / software / language you are using to program it. I believe this should be on the general section instead of pixel art critique

Since it is already here, you could improve the sprite quickly by removing the banding on the sword, front arm and front foot. Try to reduce those gradients, use less shades to define their shapes and try to make the arm, swords and feets be made of big clusters of pixels of the same color. While you are at it, t would be nice if you were to reduce the noise in the floor and stair tiles, it hurts legibility, prefer flat surfaces or, again, textures made of big clusters and of low contrast.
As for your question, you can do that before the assets are loaded on the game, or during runtime.
To do it beforehand, go by Curly's explanation using image editors.
To do it automatically on runtime it depends on the engine. If you use game maker, there are a number of assets to do just that, and I recommend Pixelated Pope's pallette shader on the market, it is cheap and effective. If you are using unity or another engine the solution is likely a corresponding shader that does the same, give google a go.
