Depends on the situation - close family members - parents, siblings etc.. sure I'd tell them.
Some friends I'd be completely open with though mostly because they work in the same industry etc... likewise friends who work in similar industries... can also chat about general comp etc... whatsapp groups can be quite interesting in this context - one friend (dunno how he got hold of it) had a copy of an internal HR spreadsheet detailing pay ranges for job titles and areas for a large US bank. Similar thing happened at a firm I worked at, open plan office, a senior manager left printout containing named individuals and their salaries + bonus on his desk!
Friends who work in the same company - gotta be a bit more careful with that, if you're talking about acquaintances/work mates you sometimes go for a drink with then... probs not. People you'd likely stay friends with after you've left the company, sure if you can trust them and vice versa then good idea to share salary info bth yours, theirs and any other info/datapoints you've obtained re: others in the company.
Always good to have a bit of mutual support even if you're at completely different companies... can be a small world - I had calls about people leaving say a firm I was working at because a mate had been asked about them at his firm where they were interviewing etc.. Earlier on in career too one mate went for a job interview, sat a test etc.. and had prepared badly... thought screw this, took his phone out and photographed all the test questions, another mate of ours was interviewing for same role - guy who'd blown it figured might as well give other mate the heads up... other mate went into the interview, obviously smashed the test and the interviewer was super excited... "that's the highest score we've ever had", he got the job & offer was top of the available range!
Other friends I know via hobbies/interests unconnected with work etc.. nope, wouldn't chat about it with them nor have any reason to - not really sure how it would ever be relevant to them.