I don't think there is an ideal way to warn people. Most functional people block off the idea of suicide altogether. Even if you are honest about your feelings, depression, and suffering, most people will never be prepared for you to leave. Likewise, more often then not if you tell people directly how you are feeling they will either think you are doing it for attention or threaten to get you "help".
I've spent so much time thinking over the same questions and how I can leave this world with the least residual damage to the people I love. I've come to the realization for myself at least that the best I can do is to put as much thought into what I leave as I possibly can. I think a good note can be enough, especially if you personalize it for each person you care about. You will never be able to prevent shock, but you can definitely explain why you made the choice you made and speak your truth, as well as tell each person who much you cared about them in a way that leaves a lasting impression.
I really do wish that I could be fully transparent about my intentions and have these conversations and closure while I am alive. It would make this process so much easier. But even if it was possible, I don't think it would ever be what is best for those we are leaving. The closer they are to your intentions, the more they will inevitably blame themselves for not being able to help. And it fucking sucks.