How can I transform a mapped BAM file into an unmapped BAM file?
Looks like you need Picard's RevertSam operation (described in context here, manual here).

java -jar picard.jar RevertSam \
     I=input.bam \
     O=reverted.bam