Url’s will be generated based on your context. if you are using the portal to render/execute your code the branch will be part of your url - simply replace /master/ with /draft/ and you should be good to go
If you want to create the attachment URL for a different branch than the one in the current context (based on requested URL as explained above), you have to wrap your call to attachmentUrl in a new context, and set the branch ‘draft’.
For this you should use contextLib.run:
var url = contextLib.run({branch: 'master'}, function () {
return portal.attachmentUrl({id: attachment.id, download: true, type: 'absolute'});
});