E.g. generating performance-critical DSP code at runtime, depending on the execution environment, e.g. cache-line width. Of course you can pre-generate common variants, but code size will be exponential in the number of parameters.
Compiling code at runtime is not self-modifying. For instance, in GPGPU programming, the kernels (=code running on GPUs) are usually compiled at runtime. And of course any time of JITs in scripting languages do the same.
What about rewriting CPU feature-detection code to remove branching?
Yeah, I think this is the answer to OP's question.
Ok, then consider a lazy-loading dynamic linker that rewrites the thunks when the library is loaded.
The linked article is not about self-modifying code, but self-modifying executable files on disk.