Yes, as long as it's compatible with your year of bike.
Can I swap out ecm with a used race ecm?
Yes, as long as it's compatible with your year of bike.
How does a guy clear codes?
Codes are cleared by sending a Clear Codes command to the ECM. This can be done with software such as ECMSpy for mono or Tunerpro RT, and a data link cable/bluetooth module. Same procedure can be used by women, too.
If you have resolved the problem that caused the trouble code, the light will go off and the ECM will automatically remove the historic code after 50 trips. If the check engine light is staying on, clearing the code won't resolve the underlying issue.