If you 'matched' through the NRMP, you have to honor the match result. If you don't and your program reports you to the NRMP you will be:
- excluded from the NRMP for 1-3 years
- have an entry in the AMA database for unprofessional conduct
If you talk to the program and get them to agree to your leaving, you can file for a 'waiver' from the match committment (or if they are agreeable with your reneging on the contract they just won't report you to the NRMP).
If you signed outside of the match, it is between you and the program. If you just signed some sort of 'I accept your job offer' piece of paper, you are in a better position than if you already signed a complete employment contract. It is unlikely that an internship program would take action against you if you tell them 3 months in advance that you won't come, but still weigh the possibility of making enemies in medicine vs the benefit of this research opportunity.