First, I don't have any insight into CLI calibre and you might get a better answer from Mobileread or by posting a bug, but my guess is that the # character must be reserved exclusively for fragment identifiers for HTML. So it is most likely a feature, not a bug.
Think about it. If the file name were allowed to contain a #, then you would not be able to ...
Converting from mobi to pdf is almost always going to be a problem. Both are rendered formats. The problem could come from anywhere. Two ideas:
First, try to obtain an epub copy instead of a mobi file. It's easier to convert from epub to pdf than from mobi to pdf.
Try decompiling the mobi file (go to mobileread to find a tool that can do so).
I’m not sure you can generate an AZK from the command line. From https://wiki.mobileread.com/wiki/KindleGen
Note that Kindle Previewer is currently the only way to generate AZK files for iOS use.
Not the answer you seek, but an answer.