Beam shaping for high-resolution imaging and sensing