Pigs should be considered farm animals as they are relatively docile, and will not run away from you should you approach.
Stand close while not holding anything and a screen prompt 'Carry Animal' will show. Press 'F' to pick up the pig.
You can not carry a pig in a vehicle.
Pigs despawn in small enclosures.
Entering your inventory, taking out a weapon or eating and drinking will drop the pig. Opening a door causes the pig to get attached to your backpack.