  If a phase transition is allowed to take place in the core of a compact star,
a new stable branch of equilibrium configurations can appear, providing
solutions with the same mass as the purely hadronic branch and hence giving
rise to twin-star configurations. We perform an extensive analysis of the
features of the phase transition leading twin-star configurations and, at the
same time, fulfilling the constraints coming from the maximum mass of
$2M_\odot$ and the information following gravitational-wave event GW170817. In
particular, we use a general equation of state for the neutron-star matter that
parametrizes the hadron-quark phase transition between the model describing the
hadronic phase and a constant speed of sound for the quark phase. We find that
the largest number of twin-star solutions has masses in the neutron-star branch
in the range $1-2M_\odot$ and twin-branch masses $\gtrsim 2M_\odot$. The
analysis of the masses, radii and tidal deformabilities also reveals that when
twin stars appear, the tidal deformability shows two distinct branches with the
same mass, thus differing considerably from the behaviour expected for neutron
stars. In addition, we find that the data from GW170817 is compatible with the
existence of hybrid stars and could also be interpreted as produced by the
merger of a binary system of hybrid stars or of a hybrid star with a neutron
star. The presence of a hybrid star in the inspiral phase can be established
clearly if future gravitational-wave detections measure chirp masses
$\mathcal{M}\lesssim 1.2M_\odot$ and tidal deformabilities of
$\Lambda_{1.4}\lesssim 400$ for $1.4M_\odot$ stars. Finally, combining all
observational information available, we set constraints on the parameters that
characterise the phase transition, the maximum masses, and the radii of
$1.4M_\odot$ stars described by equations of state leading to twin-star
configurations.
