I recommend the purchase of a 3M product to adhere the gasket to the headlamp assy ......
.
3M Trim Adhesive .......... 3M Super Trim Adhesive ........ 3M Trim/Emblem Adhesive ...... ??? ....... 3M Super Duper Quick Tack This-and-That Adhesive .......
.
I can not remember the exact name of the product(s) ........ visit your local parts store - a parts store that specializes in body shop supplies ....... they will be able to recommend the correct product.
.
I would probably begin by applying adhesive to the 'flat' sections of the gasket and then applying the gasket in place (difficult to describe what exactly the 'flat' section is) ....... when the initial adhesive is dry and the gasket will stay in place, I would then probably apply the adhesive to the other parts of the gasket ....... this method may be slightly easier and less 'messy' than applying the adhesive to a large portion of the gasket and then attempting to fool with the sticky stuff as it is going every which way ......... including all over the lens ........