William Shakespeare's Hamlet accepts a fundamentally Christian understanding of suicide as a mortal sin. This means that even in the places where Hamlet reflects on suicide, he understands that such an act would destroy his chance at eternal life and guarantee eternal torment. Thus even when he feels unhappy and without purpose at the beginning of the play and in his famous "To be or not to be" soliloquy, we should not think that suicide is a likely decision. When Horatio is so horrified by events as to contemplate taking his own life, Hamlet dissuades him.
Socrates' view on suicide is more complex. He believes that we were placed in the world by the gods who are infinitely wise and powerful. Taking our own lives rather than waiting for the gods to end our lives naturally is like being a disobedient slave of a wise and good master, and so we should not do it. Death itself is not an evil for Socrates, but his discussion about suicide focuses instead on our duty to the gods.
In Sophocles' Oedipus Rex, Jocasta's death drives Oedipus nearly mad with grief, but the issue is that she is dead, not specifically that she committed suicide. Neither Oedipus nor the chorus condemn her choice, which in ancient Greece would have been considered an honorable option given her situation. There was no general strong social prohibition against suicide in ancient culture. Some philosophical schools accepted that it was a legitimate response to certain circumstances, while others opposed it.