Couldn't get JSON_SEARCH to work but what did work was the following:
SELECT
t1.*,
JSON_EXTRACT(t1.tickets, CONCAT('$[', t1.arr_pos, ']')) AS winning_ticket
FROM
(
SELECT
c.id AS competition_id,
JSON_ARRAYAGG(t.id) AS tickets,
COUNT(t.id) AS tickets_sold,
FLOOR(RAND()*(COUNT(t.id))) AS arr_pos
FROM competitions c
JOIN tickets t ON t.competition_id = c.id
WHERE c.end_date = '2021-01-15 15:00:00'
AND c.tickets_sold > 0
GROUP BY c.id
) t1
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…