The main issue these days isn't that some tools don't know how to produce valid SAM/BAM files, it's really about the intricacies of specific types of data.
As Wouter wrote: different aligners were developed with different types of data in mind.
The main challenge for RNA-seq, for example, is the lack of a true full reference since mature mRNA lacks the introns which would be needed to align the transcript sequences to the genome. Therefore, some aligners were developed for RNA-seq alignments, optimizing spliced-read-aware alignment (STAR) and possibly isoform prediction (HISAT2). Introns can be several (hundreds) kilobases long, which is something BWA or bowtie2 would, for example, not be able to take into consideration when aligning reads.
A quick search yielded this paper that might be a good starting point to find the aligner(s) you may want to use. Generally, most benchmarks have shown that the choice of aligner (if an appropriate one for the data at hand was used) is not the most crucial one these days, so your best bet might be to think about the downstream analyses you want to do and whether any recommendations regarding a specific aligner are indicated (see YaGalbi's link for variant calling, for example).
I would like to put a reco in for
bbmap.shfrom BBMap suite.bbmap.shis a generalist aligner that can tackle data from WGS, RNAseq to PacBio. Easy to understand (and use) options. Only requirement is Java. The suite also includes plenty of other tools.Since basic SAM file format is codified, any aligner that sticks to the published format should produce valid SAM files that can be read by other tools. If an aligner does not produce standard SAM files then you should stay away from it.