It all depends on the situation. Anything with the word "never" in it is usually not quite right.
In your personal life, permanently moaning about your job is not good for you. It is better for you personally if you try to see the positive sides of your job, go to work with the intent to enjoy it. Even if you just pretend to like it, eventually things improve and you experience the job as nicer than before. Of course that's not "never say anything negative" but "try to have a positive attitude".
Or say I'm one of your friends, and there is a job opening at my company that would be suitable for you. If I think there are problems at your job I might tell you or recommend you. If I think you have a negative attitude and I don't want this to reflect badly on me, then I might not.
On the other hand, if something bad happens at your job, then asking friends about advice how to handle it is often a good idea. Or posting your problems here (anonymously) may help. So "never say anything negative" is clearly wrong.
What's dangerous is talk to people if things can get back to your company - or worse post on social media. That has happened to people in the UK: Posting "I hate my job" on Facebook can mean that your manager tells you that since you hate your job so much, they will let you find a job elsewhere (and in the UK, with a lot more protection for employees than the USA, this was legal).
And obviously don't post anything negative that could create liability for your company. Look at it from the employer's point of view: Would you want to employ that person? If you post on Facebook "I think my company ripped off customer XYZ", even if that is your honest opinion, it's something that you should have told your boss who could either fix it, or tell you why you are wrong, while posting it on Facebook might cause an expensive lawsuit, or lost customers. If you were the employer, would you like that?