Yes you can leave a buttercream frosted cake out overnight as long as the buttercream frosted cake does not contain any cream cheese.
If your buttercream frosted cake has no cream cheese then you can safely leave the buttercream frosted cake out overnight.
You can also leave the buttercream frosted cake out for 3 days before it goes bad.
If the buttercream frosted cake has any cream cheese in it then you cannot and should not leave it out overnight because bacteria can easily grow in the cream cheese on the buttercream frosted cake.
If you have cream cheese in the buttercream frosted cake then make sure you refrigerate it within a few hours of making it.