The most straightforward way is using CrossMap
.
Taking from hg19 to hg38 as example:
pip install CrossMap
CrossMap.py bam -a hg19ToHg38.over.chain input.bam output
#.bam extension will be added automatically
genome liftover chain files can be downloaded here: http://hgdownload.cse.ucsc.edu/goldenpath/hg19/liftOver/ (change according to your needs)
It is suggested to always use ‘-a’ option according to the CrossMap website.
Source:
http://crossmap.sourceforge.net/#convert-bam-cram-sam-format-files