Tell them Yourself
It is important that you be the one to tell your friends instead of keeping it a secret from them due to their fertility issues, because that will only highlight the fact that you ignored them because of their problem and did not want them to feel embarrassed, making the whole situation even worse.
Remember, your friend with fertility problems has as much right to know as anyone else.
It is very important that you give space to your friend(s) after sharing the good news. Not everyone will react the way you are expecting, which is why giving space is very essential. You should not pressurize your friend(s) to celebrate the news or visit any parties you throw. Give them time to think over it and decide how they want to proceed.
Do not feel sorry, or show that you are apologetic for their condition. They might not even be thinking about the lack of their chances of having a baby and may want to focus on your happiness, but your shallow apologies will only aggravate the situation even more.
Making assumptions on how someone with fertility problems will feel when you break the news about your pregnancy is something that you should not be doing. Everyone has a different way of reacting and all you need to do is respect their feelings. If you feel your friend(s) might uncomfortable being in a crowd when you make the announcement, you can do so in private.