I have done this with tooth paste but not shaving cream but don't see why it wouldn't work.

If you have a travel or sample size tube and a larger one put the open ends together and by sqeezing the...