How can I trigger the creation of a .DS_Store file in a directory?
I would suggest creating a folder from the terminal.  Inside the folder create a temporary folder and a temporary file.  From the terminal, open the directory in finder, create a new folder, and rearrange all of the items.  After messing around, check the terminal to see if .DS_Store is created.
Here are the steps:

Open Terminal
mkdir Folder
cd Folder
mkdir MyFolder
touch MyFile.txt
open .
Menu &gt; Sort By &gt; None
Menu &gt; File &gt; New Folder &gt; &quot;Temp&quot;
Move all the items around
In terminal, check to see if the .DS_Store has been created.

P.S. I am running macOS 11.1