X, owned by Elon Musk, has agreed to pay a $10 million settlement in a lawsuit brought by US President Donald Trump.