[verb (plain)] + だろうに [i-adj] + だろうに [na-adj] / [noun] + だろうに [na-adj] / [noun] + だった + だろうに
だろうに is だろう with のに on the end – "it surely would have…, and yet" – and usually follows a past verb with a condition in front, regretting that things went otherwise. Verbs and い-adjectives take the plain form; a noun or な-adjective takes だろうに directly, or だっただろうに for the past.
The sentence often stops at だろうに and leaves the real outcome unsaid. When it carries on, the second half says what actually happened, and often reproaches someone for it.
だろうに sounds written or a little dramatic. In conversation, plain のに does the job: がんばれば頑張ればごうかく合格できたのに.
About someone else's feelings, だろうに means "it must have been…, and yet". The speaker imagines how hard something was and sets it against how the person behaved. さぞ in front strengthens the guess.