You spend it after the roll.
The moment in the answer of that other question is how is it because, there, you they are making the roll with Advantage, and therefore you cannot roll properly with Advantage unless you roll both dice simultaneously.
There is no similar need to roll simultaneously here, as this use of Luck does not involve Advantage and only superficially resembles another question about the use of Inspiration. So, that precedent discarded as unrelated, which leaves us with only the text involved.
Shooting simultaneously with another person requires coordinating with them, and it's quite unusual in RPGs (and unheard of in D&D) that if it had to be done for any reason, it would be mentioned in the text. Then we can rule out simultaneity. (That does not rule out having to decide before the other attack roll is revealed, but I'll get to that in a minute).
The trigger is "when an attack roll is made against you." This is after The roll has been made. If the decision had to be made before the roll was made, I would say so either by saying you have to decide before you know the result of the roll, or by giving a trigger that occurs earlier such as "when you are attacked." It doesn't, so the ability and decision are activated after the die is rolled.
But perhaps the decision is after the die roll, but before knowing the result? This is possible, especially if your DM is making NPC / monster dice rolls behind a screen. But, that is not the provision that 5e assumes: it would not be taken as given, as default, in how the rules are written. But even for hidden scrolls, the default would be for you to decide after the scroll is revealed – you can't react to a scroll you don't even know is about your character! Since the trigger requires the attack roll to be made against you, and it is not "when you are attacked", you do not need to decide when a secret DM simply says that you are being attacked: you must wait for the attack roll to be resolved, including the result is, regardless of whether this result is the number obtained or if you are informed that you are "right". Restrict house rules around hidden DM dice rules, of course this could be different on your table so I want to emphasize that I am only seeing what the rules seem to assume to be the default ones sans House rules.
This is too complicated a way of saying, "You throw it after the attack, because the trigger is an attack roll that was made in the past tense."
However, the answer is that simple and could have been written that simple. It's only longer because it takes an effort to untangle it from the unrelated problem of that other question first, and then, once you're getting past an idea with an analysis of language and logic, the rest falls apart if you don't do it with a grade. similar rigor. But that's the real, tangle-free answer: you choose later, because the trigger says so.