If you are legally taking Suboxone and fail a pre employment drug screen for buprenorphine is it legal for them to deny the job?

Probably not. If you are taking prescribed buprenorphine, you may fall under the protection of the americans with disabilities act. If so, you are entitled to accommodations for your disability if our employer has more than 50 employees and meets other criteria. Get your doctors note doctor that the Buprenorphine is prescribed and you and the medication are under medical supervision. Then take the test.
What job? Depends on the type of job and the employer's policies. Majority of the time it is not tested for. Imagine running out of suboxone on a submarine or a space shuttle! find out the employer's policies and if they made a mistake and you really want the job, can ask your prescribing doctor for support.