I have solved this issue by using hidden textarea element.
modalBody is the text that will be copied.
<div class="slds-modal__content slds-p-around_medium" id="modal-content-id-1">
<p>{!v.modalBody}</p>
<TEXTAREA ID="holdtext" style="width: 0px; height: 0px; opacity: 0;">
{!v.modalBody}
</TEXTAREA>
</div>
<footer class="slds-modal__footer">
<lightning:button aura:id="copy" variant="neutral" label="Close" iconName="action:close" iconPosition="left" onclick="{! c.close }" />
<lightning:button variant="brand" label="Copy" iconName="utility:copy_to_clipboard" iconPosition="left" onclick="{! c.copy }" />
</footer>
On the controller:
copy : function(component, event, helper) {
var holdtxt = document.getElementById("holdtext");
holdtxt.select();
document.queryCommandSupported('copy');
document.execCommand('copy');
var source = event.getSource();
source.set('v.label','COPIED!');
setTimeout(function(){
component.set("v.showModal", false);
}, 1500);
}