The basic method is
--Get the ship handle
ship = mn.getShipByName("Ship name")
--Get texture handle
tex = gr.loadTexture("newtexture")
--Swap the old texture with the new one with texture replacement
ship.Textures["oldtexture"] = tex
Doing it with a RTT-generated texture is a bit more complex, but uses the same basic method.
--Get the ship handle
ship = mn.getShipByName("Ship name")
--Create texture, if needed, and draw to it.
if not tex then
tex = gr.createTexture(512, 512, "Dynamic")
end
--Set drawing target to the new texture
gr.setTarget(tex)
--Set color to yellow and draw "moocow" on the new texture
gr.setColor(255, 255, 0)
gr.drawString("Moocow", 0, 0)
--Reset render target
gr.setTarget()
--Swap the textures
ship.Textures["oldtexture"] = tex