It varies by country, but the honest truth is it's hard to do so in a 100% free fashion. It might be possible, but as other commentors have stated, you will potentially have to alter or restrict the way in which you discuss it, and may not be able to truly express how you feel.
I live in Canada. Here, healthcare practitioners of any kind are legally obligated to break patient-practitioner confidentiality and activate other appropriate resources if they have a patient/client who is a danger to themselves or others. This obviously encompasses suicide, but it also encompasses homicide or even other things, like if someone confessed to an ongoing violent crime or something like that such as beating or otherwise assaulting/abusing a child in their care.
There is some nuance here. Is someone who occasionally thinks "what if I didn't wake up tomorrow" a danger to themselves? I would argue probably not. I would wager that a considerable amount of the population has thoughts like these, and while abstract thoughts or desire to be dead is technically suicidal ideation, I would be surprised if anyone in a modern clinical setting would be detained into medical custody for this.
Where I work, we use the C-SSRS (Columbia Suicide Severity Rating Scale) to determine suicide risk. It assesses for the following:
1. Abstract thoughts "I want to be dead"
2. Non-specific thoughts, no intent "I think about killing myself"
3. Specific thoughts, no intent/plan "I think about hanging myself, but would never actually do it and have no rope"
4. Non-specific thoughts, with intent "I am planning to kill myself, but don't know how"
5. Specific thoughts, with intent "I am planning to kill myself and I have sedative drugs at home"
As you get further down the list the more severe it is. 1, 2 are considered low risk. 3 is considered medium risk. 4 is high risk, 5 is extreme risk. I would say if you confess to being at 1 or 2 you would be safe. 3 is probably safe but might want to be careful and depends on the therapist, 4 I almost certainly avoid, and 5 I would not even consider.
Also worth considering the health system you live in. Many health systems are overloaded, and sometimes people who meet criteria to be in a psychiatric inpatient unit are turned away due to capacity and demand.
If a healthcare practitioner knows you have intent to kill yourself and are therefore a danger to yourself but fails to report it, it is putting them in danger. If you were to go through with it, they would likely be investigated. In Canada any suicide is automatically considered a suspicious death and police will always investigate it, at least to some extent. If it is found out that a mental health practitioner failed to report that you were a danger to yourself, they could lose their license or even be charged with negligence, gross negligence, or probably some other crimes. Depends on the specific case and circumstance.
Our health system is pro-life. From a pro-choice perspective, this is obviously punitive to some extent. Be safe, and I'm sorry for the way you're feeling. I hope you can get the help you need.