If you're using public Tor nodes, as opposed to bridges, it's not really feasible to prevent nodes from knowing whether they're being used as middle nodes (they can just check whether the previous node corresponds to another node in the public directory consensus).
https://2019.www.torproject.org/docs/faq.html.en#ChoosePathL...
If you're using public Tor nodes, as opposed to bridges, it's not really feasible to prevent nodes from knowing whether they're being used as middle nodes (they can just check whether the previous node corresponds to another node in the public directory consensus).