I tried making structures using lone pair of oxygen but I am unable to achieve a structure which doesn't violate the octet rule.
-
$\begingroup$ You should shift the pi elctrons in -C=O on O. $\endgroup$ – Kenzo Tenma Jun 20 '20 at 8:19
Well, yes, the mesomeric effect is shown by the carbonyl group. It's an electron withdrawing group.
What happens here is that since the oxygen is a highly electronegative atom, it will tend to pull the $\pi$ bond electrons towards itself. Thus, the carbon becomes electron deficient i.e. it has it's electrons drawn towards the oxygen.
So, we can safely say that a $\ce{-C=O}$ i.e. the carbonyl group is an electron withdrawing group. So, it has a -R/-M effect.