I agree with @Justcheckingout, that's perfect. Also depending on how you are, it might be discouraging in a sense, if you await their reply or want to see how they respond. It's more stress and delay, if that makes sense.
If thanking them for the friendship randomly is out of character, maybe try emphasizing that you know it's strange? Like "hey man, I know this sounds mad weird but thanks for being my friend. No need to worry, I just felt like appreciating you a lil since i know i never say that often enough." If you do it during/after a happy conversation it'll seem even more spur-of-the-moment and less sus.
Does your friend know about your suicidal ideation though? If they're familiar with it and you have a history of attempts, I'd be wary about saying anything at all, honestly. Ngl, anything you say could make your friend feel very concerned and guilty if you are known to be "at-risk." They might call the cops on you or something, especially if you send the message and ghost right after. If they receive a message, do nothing, and then find out about your fate later, the guilt they feel will be immense. That sort of thing can really mess with people for life. I mean, in the end it doesn't really matter, but it's something to consider.