It does seem like a gray area, and I would guess that what's right or wrong varies massively. I've seen a lot of stories show heists in museums with IRL artifacts. The Hope Diamond or Crown Jewels, as well as many works in the Louvre seem to be popular targets. Harry Dresden stole the Tyrannosaurus rex Sue from the Field Museum in Chicago. Black Panther, for example, had Killmonger steal artifacts from The British Museum, and it was explicitly The British Museum because Killmonger had a long speech about some of the museum's controversial policies. However, whether that's legal or whether the museum could turn around and sue you for defamation is a gray area.
What would be a make-or-break thing in such a scenario is if you're painting the museum in a bad light, and how close to the real security systems your story is. If you paint the museum as corrupt, incompetent, etc., the museum is more likely to take offense and sue you. Similarly, if you give people a real guide to circumventing security systems and quasi-successfully steal artifacts from a museum, complete with details of room layouts to avoid security cameras and such, that might be grounds for a lawsuit.
One thing a lot of museum stories do is make fake museums that don't resemble the real thing at all. For example the museum in the Night at the Museum series looks absolutely nothing like the actual American Museum of Natural History in New York City. The AMNH lacks any wax sculptures of humans (so no miniature cowboys and Romans, no Sacagawea, and no Robin Williams-as-Theodore Roosevelt), has no mummies on display aside from one of a duck-billed dinosaur, the "gum-gum" moai seen in the film is actually a replica made of plaster, and the layout of the museum looks nothing like the real deal (for starters, the entry rotunda of the AMNH is four times the size of the one shown in the film and has an Allosaurus and Barosaurus on display, not Tyrannosaurus rex). Some of the museum's displays are famous throughout the world (including the Allosaurus and Barosaurus display, the taxidermied elephant and gorilla displays, the blue whale in the ocean hall, and the Williamette meteorite), and pretty much none of them show up in the films. The museum in general is a lot bigger than the movie presents it as well, the bare-bones security guard force is plot relevant but the AMNH currently requires 186 guards to keep the entire faciity patrolled because it's just so big. The thing covers an entire city block in New York City. A lot of this is probably to avoid potential lawsuits, since the AMNH is technically a privately owned organization rather than a public facility.
So I think a lot of it depends on how you present the museum, in how much detail do you show the museum's inner workings, and how closely does your fictional depiction of the museum resemble the actual thing (including its security systems).