You might think material.CopyPropertiesFromMaterial would fully copy one material into an existing one but as the docs say it does not do the shader, so you have to set that also.
But avoiding the message in the console (in 2021 editor) “Render queue value outside of the allowed range…” when going from one render queue choice to another seems unavoidable. Setting the shader first fixes one way not the other.
Is this a harmless message or a bug?
Why can there not be a single function call to copy everything from one material to another without warnings?
Edit: This bug may come from the editor inspector! Create a Standard Cutout Material and set the “Render Queue” to “From Shader” - same message. Something is broken in Standard Materials