Meta, the social-media giant, has agreed to pay up to $16.68 billion as part of a settlement in a social-media addiction trial, leading to a rise in its stock price.