What you're specifically asking about wouldn't even require altering code: It would be a simple palette data edit.
Using an emulator like FCEUX will allow you to view the palette table via it's PPU debug menu. This table holds four, four color palettes for background tiles,with the first color shared across all four palettes, and four, four color palettes for sprites (Though the first color is actually transparent in each set of four)
The actual colors are stored in an index, with each color represented by a specific hexadecimal value. Most typically, the order the palette values are listed in the table is the order you will find them in the ROM (Hover over a color in the PPU Viewer to see a color's hex value). Use FCEUX's Hex editor to view the ROM data to do this.
Note that if you aren't finding matches for all four sprite palette colors omit the transparent value and you'll probably have better luck: This is common going by the dozens of games I messed with over the years. Changing the colors will be as simple as substituting new values.
Do be aware that most graphics will share palettes, so altering a palette will typically have a side effect of changing their colors as well.
A thorough explanation of all this can be found here (Along with a chart that shows you all the color values):https://wiki.nesdev.com/w/index.php/PPU_palettes