YouTube has agreed to pay $24.5m (£18.1m) to settle a lawsuit brought by Donald Trump after it banned his account following the January 6 Capitol riot.