My perspective for what its worth...
People telling you they rank you number one only to go elsewhere absolutely makes PD's not trust other candidates who say the same thing. And programs telling candidates that's they rank them to match and candidates not matching there does the exact same thing.
In the end the general answer is you should never lie about the stuff, but people understand things change sometimes. If something changed, it changed. You are under no obligation just because you told program you were writing them number one to still write them that. It does hurt your credibility, but I certainly wouldn't write a letter telling a program that you no longer a ranking them highly before the match.
I personally think a good way to handle your specific situation is to wait until after the match. If you match elsewhere at the program you ranked higher than the one you said was #1, you could shoot a quick email off to the PD and explain. Complementing their residency program, telling them you had every intention of ranking them first but you had a social change which changed your rank list at the last second. And wishing them the best of luck with their current residency class. That actually happened to us last year with a student we really thought highly of, and we didn't begrudge him at all because he wrote to us and thanked us afterwards and explained what changed. If he ever needed a job and we had an opening, we would never hold it against him.
More generally on this topic, in the end does any of it matter if you lie if you are the sudent or program? It matters if you honor your credibility. Is there any other repercussions to you? Absolutely not. But I do agree that PDs remember people who lie to them. That's not being petty. It's unprofessional to lie to someone. Especially when a program spent a month providing a rotation, housing, food, writing a sloe, and the school evaluation for you. A lot of time goes into training medical students, I don't think it's unreasonable to ask for people to just be professional and not lie to one another when a program spent a lot of time helping your application. You don't owe anything to any program in terms of where you rank them. But I do think you owe people common courtesy to not lie. That goes both ways.
I do agree that if you ran into somebody at a conference it would be petty for them to bring it up. Hell that person that lied to you in the end did you a favor, because in the end you don't want to populate your residency with a bunch of unprofessional folks that lie anyways. But on the otherhand, I think it would be very difficult to hire a residency graduate to be faculty at your program from another residency, if you knew that person lied directly to your face three years before. And yet there are tons of students who have chosen to go elsewhere who I would support hiring in a second when they graduate from another program. It's not about not being wanted; that WOULD be petty. It's about not being an adult professional and lying, and those are two very very different things. I'm sure this is exactly the same from the student end. If a program lied to you as a student, and you didn't match there, I hardly think if they were hiring three years later you would sign a contract there. There's no point in associating yourself with people who are not professionals.
Just my 2 cents...