Technically not unless you go that way on a direct train, i.e. one of the TPE services which run this way overnight or during engineering works.
In practice I doubt it would be questioned and if it was, explaining you're changing at Castleford would likely result in it being accepted it as it's a perfectly reasonable route. It's no longer than travelling via Harrogate, which is of course perfectly valid.
It should be added to the Routeing Guide as a permitted route for journeys like this, but sadly the industry is very reactive rather than proactive when it comes to things like this.