If you are using materials, you can just put the name of texture into the materials xml, such as the material/stone.xml:
<material>
    <technique name="Techniques/DiffNormalPacked.xml" quality="1" />
    <technique name="Techniques/Diff.xml" quality="0" />
    <texture unit="diffuse" name="Textures/StoneDiffuse.dds" />
    <texture unit="normal" name="Textures/StoneNormal.dds" />
    <parameter name="MatSpecColor" value="0.3 0.3 0.3 16" />
</material>
Just change the textures file to yours.
Then I used something like this to create custom texture on the fly. Although I do still need to use material file of a model.
	// Using some random material to create image that we can use for our painted texture
	auto mat = cache->GetResource<Material>( "Materials/UrhoDecal.xml");
	auto tex = SharedPtr<Texture2D>( new Texture2D(context_));
	tex->SetSize(0, 0, 0, TEXTURE_DYNAMIC);
	mat->SetTexture(TextureUnit(), tex);
	auto img = SharedPtr<Image>(new Image(context_));
	img->SetSize(512, 512, 4);
	img->Clear(Color(1, 1, 1, 1));
	for (int y = 0; y < 128; ++y)
	{
		int x = 0;
		for (; x < 128; ++x)
			img->SetPixel(x, y, Color((float)rand() / RAND_MAX, (float)rand() / RAND_MAX,
				(float)rand() / RAND_MAX, (float)rand() / RAND_MAX));
		for (; x < 256; ++x)
			img->SetPixel(x, y, Color(0.5f, 0.f, 0.f, 1.f ));
		for (; x < 384; ++x)
			img->SetPixel(x, y, Color(0.0f, 0.5f, 0.f, 1.f));
		for (; x < 512; ++x)
			img->SetPixel(x, y, Color(0.3f, 0.3f, 0.8f, 1.f));
	}
	tex->SetData(img, false);
I am not going to lie, I did find the code from internet and modified it, so honestly I have no idea what the TextureUnit is, but it seems to work, which is good enough for me.