Study of the lineshape of $X(3872)$ using $B$ decays to $D^0\overline{D}{}^{*0}K$