You can also ride a road bike on some sick singletrack, but it’s probably not gonna be as pleasant as riding a proper bike for that use.
It’s similar the other way around, just less dangerous.
The main concern about riding a mountain bike on a road is not even a concern at all, it’s just a slight disadvantage. Mountain bikes use knobby tires, and those create a lot of rolling resistance on pavement, so you’re not going to go as fast, you’re not going to be as efficient and you’re not gonna be able to ride it as well as a bike with proper design for the road because the tires are dragging a lot and they are slowing you down. If the knobs are too tall, you can have reduced grip too, because not a lot of the tires contact area will be in touch with the ground as it could be with a slick tire (no knobs).
But you can put slick tires and you’re pretty much just as good. The only disadvantage left is that mountain bikes have a more aggressive geometry that is suited to tackle technical terrain, and since you’re on a road, you won’t find that kind of terrain…which means you would be better with a bike that is better on the other side of the spectrum which is pedaling and aerodynamics, like a road bike.
Moutnain bikes are usually heavier too, so they would be harder to pedal uphill.
But again, is not even a “concern”. Just something that isn’t the best possible option.
So in short. Should you? I don’t know, but there’s absolutely no reason to avoid it unless you’re racing on a road or looking to be as efficient as possible while pedaling.