Hong Kong has passed a new national security law that critics fear will further erode civil liberties in the China-ruled city.