Can I use a 2N3904 transistor in place of a 2N4401 if I flip it around?
According to these two datasheets, one for the 2N3904 and the other for the 2N4401, they have the same pin configuration, namely E B C with the flat side facing you.



Looking at the other parameters of the datasheets, they look very similar (the h\$_{FE}\$ of the 2N3904 is just slightly higher), so you should be able to get by with the substitution.