I don't think you could dye the solder mask, but you could remove it by boiling the PCB in a solution of sodium hydroxide (NaOH, a household lye).
The substrate material can be dyed in hot dye baths using the same dyes as for PBT plastic (Rit, iDye or whatever is available in your area) but a permanent marker pen in the desired colour might be easier.
I have recoloured a purely decorative and unpopulated PCB this way. I wouldn't do this with anything remotely complex (the solder mask is there for a reason) or to one that has any components on it.