To avoid, that effort gets invoiced several times, you can only make one main association for a task either with a project or a ticket. If you want to associate other objects for quick reference, you can use the general association function.
First open the task. On the right side you can add associations by clicking on the + sign.
You can choose any type of object, not only projects and tickets.
All associated objects will be shown on the right side.