Only 1 Applicant Asked To Do Free Labor Before Interview

I applied for a new job in the same department where I already work. The department head stated they don’t want me to leave my current role; at first they said I could not be considered for the new role, but have relented that I can be considered only if a very thorough search is done for better candidates. I applied, and now I’ve been asked to complete a non-trivial task that the new role would do; it hasn’t officially been stated as a technical competency test as part of the interview process but it feels like it. Other candidates are not being asked to do this.
Obviously the situation feels gross and if I had viable prospects elsewhere I would take them (I need to change my job role due to health issues but they are inflexible about revising my current duties and accommodations aren’t able to address the problem.).
My question is: is it illegal to ask only one applicant to pass a technical test (and/or do multiple hours of labor for free during the application process)? I’m possibly the only female applicant. I am in the US.
[link] [comments]