Probing magnetar magnetosphere through X-ray polarization measurements