It very much depends on the production.
In many modern productions soliloquies and some humour are performed to the audience or a even a wink or aside to the audience.
But that doesn't mean they're unambiguously fourth wall breaking in the text.
Hamlet probably wouldn't in real life enunciate his famous speech and it's surely a theatrical device. But just because something is present that wouldn't be present if the audience were not doesn't mean the fourth wall is broken.
That might be eye contact or a hand to the side of the mouth against the other players directly lines to the audience that indicates the actor is directly interacting with the audience.
For example, Julius Caeser musing how many future generations will watch the scene is slightly humourous and deliberate irony. Whether the wall is broken is how he delivers the line.
There's bawdy humour in Shakespeare so without any historical record I'd guess some it went on.
There's a line in Hamlet that is often interpreted as a pop at Will Kempe (one of the players who had maybe left or was certainly starting to fall out with everyone):
and let those that play your clowns speak no more than is set down for
them. For there be of them that will themselves laugh to set on some
quantity of barren spectators to laugh too, though in the meantime
some necessary question of the play be then to be considered.—That’s
villainous and shows a most pitiful ambition in the fool that uses
Hamlet, Act 3 Scene 2
With no evidence I can only imagine some gesture being made to indicate who was meant - big laughs!