Unless for some reason there are instructions included with the particular enclosures listing prohibiting painting there is no problem.
That does not include cover plates or painting surfaces that may be for EGC connections, these would require special consideration.
Roger