We study a two-site Sachdev-Ye-Kitaev (SYK) model with complex couplings, and identify a low temperature transition to a gapped phase characterized by a constant in temperature free energy. This transition is observed without introducing a coupling between the two sites, and only appears after ensemble average over the complex couplings. We propose a gravity interpretation of these results by constructing an explicit solution of Jackiw-Teitelboim (JT) gravity with matter: a two-dimensional Euclidean wormhole whose geometry is the double trumpet. This solution is sustained by imaginary sources for a marginal operator, without the need of a coupling between the two boundaries. As the temperature is decreased, there is a transition from a disconnected phase with two black holes to the connected wormhole phase, in qualitative agreement with the SYK observation. The expectation value of the marginal operator is an order parameter for this transition. This illustrates in a concrete setup how a Euclidean wormhole can arise from an average over field theory couplings.