/** int $orderId ID заказа */
$order = \Bitrix\Sale\Order::load($orderId);
$collection = $order->getShipmentCollection()->getNotSystemItems();
$needShipment = null;
foreach ($collection as $shipment)
{
//В примере выбирается первая отгрузка. Опишите выбор отгрузки так как вам надо
$needShipment = $shipment;
break;
}
if (!is_null($needShipment)) {
$needShipment->setField("TRACKING_NUMBER", 'xxxxxxxxxx');
}