Weld a section of flat stock in the one pipe end protruding at least 1 pipe diameter. Cut slots and weld in plates to make a yoke to accept the tang on the other part. Drill a hole for a piviot pin. If You need to lock it in the straight position slide a section of close fitting pipe over the joint, length should be 4-6 x the pipe diameter.
If You need to fold 180 degrees use a yoke on each pipe end and a tang with a hole in each end. The tang has to be long enough to let the pipes fold parallell, that is the pin center spacing must be at least the diameter of the pipe plus the wall thickness of the locking sleve.