There is no evidence for the claim that HS2 will cost Scotland. In effect, all money spent by Scotland on HS2 is returned through the Barnett formula.
When the UK government increases spending which doesn't affect a devolved nation, that devolved nation receives money, equivalent to its population share, back to spend itself. This is the case with HS2 and Scotland which means that, in effect, all money spent on HS2 which is raised by Scottish taxes will be returned via something called the Barnett formula.
Also, while HS2’s high-speed lines will not reach Scotland, HS2 will cut the travel time to and from Scotland in some cases, because HS2 trains going between Scotland and England are expected to run on the high-speed lines in England before or after moving onto the regular network.
HS2 is being paid for by the UK Department for Transport. This is funded by public money including taxes gathered across the UK.
We can’t really say the extent to which taxes collected in Scotland are contributing towards HS2 because bits of government revenue aren’t generally earmarked for specific projects.