The purpose of all headliners is strictly decorative, to hide the steel with something a little softer and better to look at. You will absolutely not want to spray foam insulation up there. How on earth would you smooth it out to get a decent base for the fabric? And if you did spray it up there and managed to cover it with fabric, how do you know it wouldn't let loose and fall in your lap? Also, it would squeak like a thousand mice. Headliners for your truck are not hard to find.
No one lives forever, the trick is creating something that will.