I have looked for an answer for this question which seems trivial, but I didn't find any.
Can a Turing machine, given a word w, calculate the length of the word?
Yep, certainly! Here’s something to think about:
Another perspective: remember that by the Church-Turing thesis anything you can do with any effective model of computation you can do with a TM, so since other models can measure input length, TMs can do it as well.