Planck intermediate results. XI. The gas content of dark matter halos: the Sunyaev-Zeldovich-stellar mass relation for locally brightest galaxies