One of the reasons ADHD affects attention so severely is because a brain with ADHD is basically under-stimulated. A person with ADHD craves mental stimulation, which is why people with ADHD tend to jump from one activity to another the instant an activity becomes boring. If you need to knuckle down on one single task that can’t be split up easily, a good technique is to have something running in the background that gives your brain the stimulation it wants.
There’s a number of ways to stimulate your brain this way; music is a common one, listening to a podcast or radio show is another, and fidgeting with a toy or other stim object is a widely-used physical stimulation. The important part is that the distraction should never be something that takes over from the task at hand; if you put some music on, make it a song you’ve heard before, preferably without lyrics. If you listen to a podcast, make it an episode you’ve already listened to. If you use a fidget toy, use the same one all the time.
Whatever you do, make sure it’s something that doesn’t provide any new information or stimulation to your mind; make it a familiar sound or action that simply provides background noise to keep your ADHD satisfied.