Please review the Q&A Usage Guidelines before posting, specifically point 3, "Quote the applicable rule from the latest version of the manual in your question".
Rule R22 reads as follows, with a portion bolded for emphasis:
<R21> No modifications to electronic components are allowed. Motors (including the internal PTC or Smart Motor firmware), microcontrollers (including V5 Robot Brain firmware), extension cords, sensors, controllers, battery packs, reservoirs, solenoids, pneumatic cylinders, and any other electrical component or pneumatics component of the VEX platform may NOT be altered from their original state in ANY way.
[...]
c. Teams may make the following modifications to the V5 Smart Motor’s user-serviceable features. No other modifications are permitted.
i. Changing or replacing the gear cartridge with other official replacement cartridges.
ii. Replacing the V5 Smart Motor Cap (276-6780).
iii. Replacing the threaded mounting inserts (276-6781).
Provided that no modifications are made other than replacing the V5 Smart Motor Cap, this would be legal.