A study of the blood of people who have attempted or committed suicide indicates that the potential risk might be discernable with medical testing. From the Molecular Psychiatry article:

Taken together, our results have implications for the understanding of suicide, as well as for the development of objective laboratory tests and tools to track suicidal risk and response to treatment…
Given the fact that approximately one million people die of suicide worldwide each year, and this is a potentially preventable cause of death, the need for, urgency and importance of efforts such as ours cannot be overstated.

Interesting and hopeful. Of course, that assumes society will still be interested in preventing suicide by the time this technique could be developed.