No, in general a word can not function as both a subject and an object.1
In your sentence, "that" is a relative pronoun referring to "a cup of tea" (or perhaps just "tea"). Within the relative clause, it functions as a subject. I'll put it in bold type below.
The relative clause is a bit complicated because it includes what can be considered a reporting clause: "he knew without tasting". Removing it, we get:
She handed him a cup of tea [that would be exactly as he liked it].
It is now clearer that "that" is the subject of the relative clause (which I've put inside brackets). If we wanted to re-write the relative clause as an independent clause, we'd get:
That would be exactly as he liked it.
We can make this clause (which I'll put into brackets again) an object of the original reporting clause:
He knew without tasting [that that would be exactly as he liked it].2
This is similar to the sentence that you ask about at the end of your question.
1There can be exceptions to this rule in some situations, but they wouldn't apply here.
2Because the clause now functions as an object, I've introduced it with the subordinating conjunction "that".