The Department of Justice on Friday formally opposed an effort by Facebook to dismiss a lawsuit by several housing groups, arguing that the social media platform may be held legally responsible if advertisers violate fair-housing laws by using its ad-targeting tools.