You can create a hidden input where you can fill your text and copy it from there.
The only challenge is you can not fill values to hidden input and then select + copy. You first need to select, copy from it, and then set the input type to hidden.
function copyText(text) {
var placeHolder = document.createElement("input");
documeny.body.appendChild(placeHolder);
placeHolder.setAttribute("id", "placeHolder");
document.getElementById("placeHolder").value=text;
placeHolder.select();
document.execCommand("copy");
document.getElementById("placeHolder").type ='hidden';
}
<button type="button" onclick="copyText('copied text')">Copy</button>