IME, they measure the baby's head/limb/stomach etc via a scan.
They then plot it on a graph, much the same as the growth after birth charts.
Thing is they are only accurate if there are a good number of results, i.e. quite a few scans, if your baby is a standard rate of growth, i.e. follows a centile continuously and if you have the exact dates for conception.
With DS2 I had an almost exact guess for his weight but my LMP and Scan both showed the same time of conception, which matched with when we had had sex, so my graph was plotted accurately, but there is no way to be sure with every pregnancy, also DS2 followed a standard centile, and I had scans every 2 weeks.