For materials, of course you could. That would be pretty simple. Just iterate through the material properties you’re interested in and print their values to a file. As for textures, it would work the same as long as they’re procedural. Of course for textures from a loaded image, well, you just have the file.
I’m just not sure what use it would be to save these mat/tex parameters to a file when you can just link or append them from an external .blend.
But if you mean you want to create - ultimately - a script that uses the materials or textures you had saved, then you can create procedural textures and materials within your python script.