Suicidal thoughts themselves are not sinful. It is the action that is a sign of despair, of giving up that is sinful.
If you do have “dark thoughts” for whatever reason do get help.
Some medications have side effects that include depressive thoughts, including suicidal thoughts.
It is important not to dwell on them, and to seek professional help as quickly as possible, even if it only a fleeting thought.
The professional can help you get to the real issue triggering any dark thoughts, any issues that need to be dealt with.
“Suicide is a permanent solution to a temporary problem.” Find out what the problem is. Pray for guidance, and solutions, even if that solution is to simply let go and give the problem to God.