The halfling's Lucky trait deals with the die roll (PHB, p. 28):
When you roll a 1 on an attack roll, ability check, or saving throw, you can reroll the die and must use the new roll.
And so does Advantage/Disadvantage, since it refers to the same trait (PHB, p. 173):
For example, if a halfling has advantage on an ability check and rolls a 1 and a 13, the halfling could use the Lucky trait to reroll the 1.
The Divination wizard's Portent feature, on the other hand, deals with the check as a whole:
You can replace any attack roll, saving throw, or ability check ... with one of these foretelling rolls.
And here comes the interesting part - the three emphasized terms are only mentioned in rules as actions, not numbers:
The description of attack rolls (PHB, p. 194):
To make an attack roll, roll a d20 and add the appropriate modifiers.
If the total of the roll plus modifiers equals or exceeds the
target’s Armor Class (AC), the attack hits.
Saving throws (PHB, p. 179):
To make a saving throw, roll a d20 and add the appropriate ability
modifier. [...]
A saving throw can be modified by a situational bonus or penalty [...]
[...] proficiency in a saving throw lets a character add his or her
proficiency bonus to saving throws made using a particular ability
score. [...]
And ability checks (PHB, p. 171):
To make an ability check, roll a d20 and add the relevant ability
modifier. As with other d20 rolls, apply bonuses and penalties, and
compare the total to the DC.
All three go the standard way:
- Roll a d20, get a number
- In case of (dis-)advantage: roll another d20, get a new number (or
keep the old)
- Add bonuses/penalties, get the final number
- Compare the final number with the AC/DC and get the final
success/failure answer
From the strict RAW reading of Portent, we have to replace steps 1–4 (the whole check) with a number (foretelling roll), which makes no sense, as the result has to be boolean – success/failure.
If we loosen the restrictions, the logical thing to say would be "In the context of Portent, attack roll/saving throw/ability check is the number to be compared with the AC/DC" (i.e. the result of Step 3 above). In this interpretation "You must choose to do so before the roll" means that the decision is made before Step 1 and therefore no actual die roll happens. The modifiers are applied to the foretold roll as normal. This interpretation is reinforced by an unofficial tweet from March 2015 by rules designer Jeremy Crawford:
The portent die is intended to replace a d20 roll only, not any modifiers applied to it.
This result is Rules As Intended as well; the whole point is that the character knows in advance what is going to happen.
From my reading, no.
As you mention in the question:
This may come down to whether or not the Lucky roll counts as an "attack roll" itself or whether the "attack roll" was the original roll and the Lucky roll is some other type of roll.
Yes, this is the case. And Lucky is not an attack roll.
Lucky says:
Whenever you make an attack roll, an ability check, or a saving throw, you can spend one luck point to roll an additional d20. [...] You choose which of the d20s is used for the attack roll, ability check, or saving throw.
You don't make a new attack roll - you just roll an extra die and then choose which die to use for the attack roll. The Lucky itself is not an attack roll, as much as attacking with advantage doesn't let you make two attack rolls or two saving throws, it is one attack roll that has a "more complicated" math than just rolling. Until you roll the additional d20 from Lucky, you are in the middle of the attack roll (just as you would be, for example, if you were rolling with advantage and rolled one die first, took a break and then rolled the other - you are in the middle of the same attack roll). Portent specifically asks "before the roll", so you can't use it.
For another example, a damage roll consists of all the damage dice summed, e.g. 2d6. Adding an extra 1d6 does not make an extra damage roll, just an extra damage die.
Best Answer
Excellent question. Yes the legendary creature can still force a success.
How this works is portent needs to make the Legendary creature use the roll from itself before the roll is actually made, thus giving them a failing saving throw immediately. The legendary creature would then uses their legendary resistance which takes place after the roll is made and results determined, declaring the save a success as a replacement effect.