Fresh air in a room (CO2 levels), clean desk and computer desktop, adjust noise levels, offload non-essential thoughts and ideas onto paper, keep any other distraction levels down too.
This is the question to dwell on I think. I don't know if there are mental ergonomics that apply universally, or even ones that generalise well. For me, I recognise that I think well when I'm physically engaged in some other non-cognitive task, like walking, running, showering, etc.
Another key factor is eliminating the risk of interruptions. I know when I'm at my desk I'm likely to get interrupted, but times and spaces that are interruption free seem to encourage the deepest thought.
I started walking for at least 30 minutes every morning before work, and it has become a habit during this pandemic. I realized that the best ideas of solving problems came from this little exercise. Subsequently, I’ve learned to start tapping away on my phone so I can capture these ideas before I lose them since there are too many to remember well.
They didn't call it the peripatetic school for nothing. There are also cases of patients with speech aphasia who can speak while walking, but can't while at rest; it turns out that brain structures for speech and locomotion are interrelated.
I suspect this varies widely from person-to-person, but I'll share things that I find effective.
1. Create space for thinking.
Block off chunks of time. Snooze notifications. Close sources of distraction.
Set a timer/alarm so that I don't need to watch the clock. Leave a buffer between that alarm and whatever my next commitment is to wrap up/conclude.
Create a place where I capture my thinking. This could be a whiteboard, a piece of paper, a text editor, etc. I avoid nice notebooks because thinking involves writing down lots of unpolished things, starting over occasionally, etc. and I just can't bring myself to do that with a nice notebook.
2. Focus.
Pick a topic/question/hypothesis/whatever. Set up a "parking lot" for interesting things that occur to me that I don't want to get distracted with.
Sometimes it's hard to articulate what the topic is. In that case, I do some basic mind mapping of related terms/topics/whatever and then draw a box around the area I'm focus on.
Occasionally look back at the topic and make sure that's what I'm actually thinking about.
3. Work in order.
Think about the problem first, in detail, before thinking about solutions. Similar to the above, stick any inklings of potential solutions in a parking lot. This includes considering the characteristics/qualities of a good solution; this helps me avoid getting attached to any initial seemingly-elegant solutions that don't actually have the qualities I think are important (anchoring is a real thing, even if you're aware of it).
When considering the problem or solution, I try to brainstorm ideas, then organize those ideas into a "space" (either problem space or a solution space), and then figure out the key "dimensions" of that space.
Identify the key questions that narrow (e.g., bisect) that space. Focus on those, versus getting bogged down in details of an option that may turn out not to be relevant. Often, these become "next steps".
4. Separate thinking from producing.
Separate writing-as-a-way-to-think from writing-as-a-way-to-communicate. I can't do both at the same time effectively; I end prioritizing clarity over substance. Similarly, I struggle to rapidly produce useful proof-of-concept code unless I promise myself it's going to get thrown away. Readability, maintainability, accuracy, etc. are all hugely important, but not for the first stages of thinking.
Once I've finished thinking, then I can write an actual document for others to consume.