I agree with Winky, it is a big difference between keeping a private confidence that hurts nobody and telling a lie when someone needs to know the truth.
For example, my BIL took an overdose of amphetamines and alcohol the Christmas before last. He didn't want anyone to know so PILs agreed not to say anything to anyone. But rather than keep it quiet or say it was a private matter he didn't want to discuss, they made up a lie that he had a rare blood disorder that could require a lifetime on medication and might eventually kill him. They refused to give the name of this rare disorder though, claiming it was a long name they couldn't quite remember or pronounce.
Understandably everyone was very upset about it and very worried for him. But worse, his siblings, including my DH, were concerned they might have inherited the same condition and worse again, we were all worried that our children might have inherited it. DH and I were left wondering if this condition might be the reason that two of our babies died (unexplained stillbirth and prematurity) and scared our living son could become ill at any time.
So SIL spoke to her parents and they admitted to her the real reason but asked her not to tell us or their other brother (who has four children). She accidentally let it slip in a phone call to her friend that I overheard. She was upset that she had been asked to perpetuate the lie and I was upset that she knew how worried we were and still kept the truth to herself. We were about to take our son to the doctor to ask for blood tests for some unknown but potentially fatal illness his uncle was suffering from and it was all a lie.
That's a confidence that should be broken, when it is to sustain a harmful lie. All they needed to say was that he was in hospital but had asked for privacy. That was a confidence it was his right to ask for and which people could and should respect. It didn't hurt anyone and it was his own business.
But to make up such an elaborate lie, one that made his three siblings concerned for their own health and which had two of them worried for their own children as well, was cruel and wrong. And when SIL found out, that was a confidence she should have refused to keep.
If you feel you would rather break a friends confidence than say "I don't know" to someone else then you still have the option of saying "You'd have to ask X about that" or "X is my friend and I don't feel comfortable discussing her in her absence."
It would be a shame to lose friendships because they might expect you to keep a personal matter between yourselves and it must be difficult to maintain a friendship where you can't talk in confidence for fear you will break it if asked by someone else.