Big-city police departments and union leaders around the country are warning the rank and file to wear bulletproof vests and avoid making inflammatory posts on social media in the days after a man ambushed two officers and shot them to death inside their patrol car.