There are many reasons to work on scales besides the purely mechanical one. So, even if you want to acquire the “technique” by playing through pieces that have scalar passages, you should still practise scales in tandem (always pratise the scales of your pieces).
Why you should do that is detailed on these threads:
https://pianoforum.net/smf/index.php/topic,2758.msg23889.html#msg23889(scales & compositions – the real importance of scales is to develop the concept of key, not exercise)
https://pianoforum.net/smf/index.php/topic,2983.msg26079.html#msg26079(Best order to learn scales – what does it mean not to play scales outside pieces)
https://pianoforum.net/smf/index.php/topic,5003.msg47438.html#msg47438(summary of links on the importance of working on scales)
As far as the purely mechanical aspect of playing scales go, most of them can be easily solved by using proper fingering (the orthodox fingering suggested in Hanon and most scale manuals is not the best one), and by making sure you use “thumb over”. The threads below give detailed explanations for both issues:
https://pianoforum.net/smf/index.php/topic,2313.msg19807.html#msg19807(Speed of scales – the important factors in speed playing - an alternative fingering for scales).
https://pianoforum.net/smf/index.php/topic,2533.msg21955.html#msg21955(an structured plan to learn scales and arpeggios – includes description of repeated note-groups and other tricks)
https://pianoforum.net/smf/index.php/topic,2619.msg22756.html#msg22756(unorthodox fingering for all major and minor scales plus an explanation)
https://pianoforum.net/smf/index.php/topic,2701.msg23134.html#msg23134(Teaching scales – the cluster method and why one should start with B major).
https://pianoforum.net/smf/index.php/topic,2920.msg25568.html#msg25568(how to play superfast scales)
https://pianoforum.net/smf/index.php/topic,2998.msg26268.html#msg26268(Scales HT, why? – why and when to practise scales HS and HT – Pragmatical x logical way of teaching – analogy with aikido – list of piano techniques – DVORAK – realistic x sports martial arts – technique and how to acquire it by solving technical problems – Hanon and why it should be avoided - Lemmings)
https://www.pianostreet.com/smf/index.php/topic,2619.msg104249.html#msg104249(Scale fingering must be modified according to the piece – Godard op. 149 no.5 – yet another example of the folly of technical exercises)
Finally, the best way to deal with the “dullness” of scale practice, is to practice scales by using “free improvisation”.
Have a look here where the process is described in some detail.
https://pianoforum.net/smf/index.php/topic,3499.msg31548.html#msg31548(using scales as the basis for free improvisation)
I hope this helps.
Best wishes,
Bernhard.