The declaration of trust would not be a sham. Provided that the usually formalities had been complied with, the trust would not be void. That is not to say that the arrangements aren't potentially susceptible to attack by HMRC but a sham is a far too strong term.
However, It would be a sham if H, although executing the declaration, had agreed with W that it was not his "real" intention to transfer any interest; the exercise being purely to mitigate CGT.