It's hard to say because by the time you're in what would generally be considered late stage, you really aren't able to communicate effectively.
What I can say is that what communication I have had with people that far gone did not entail anything about death. They weren't doing their screaming or babbling or general word salad about death in any perceptible way. Overall, I'd say half of the patients I took care of were patients because of some kind of dementia, and I was very often there at the very end of their process.
I never had any patient close to the end that had a form of dementia as their primary diagnosis bring up death at all. Meaning, no Alzheimer's type out dementia. Now, patients that exhibited dementia-like symptoms as a result of some other condition (usually brain tumors) did, in a small handful of instances say and do things that made it seem like death was on their mind.
Out of those, there's only two where I feel confident that what they were saying was about their perception that they were dying, rather than it being more likely that it was a product of the same kind of random things that weren't a sure sign that they were aware of their dying, if that makes sense.
Someone just saying disjointed strings of things that happen to include the words death or dying, it's impossible to be sure what they were thinking or feeling. Because it could be jumbled in with completely unrelated things.
But yeah, those two in specific, I'm fairly sure that they were at least partially aware of the fact that they were near death. Both of them said that they wanted to die, at some point in the process, though they didn't always say that. One of them said they weren't ready, or that they didn't want to go yet.
I don't know, and there's no way to know for sure, what they were thinking, if it was conscious thought, or even if it was actually them rather than just misfiring brains parroting things they'd heard in the past. But I "felt" like it was them, whatever kernel of their mind was left.