With ksh93:
set -o functrace trap 'printf "\e]0;%s\a" "${.sh.command}" > /dev/tty' DEBUG HOSTNAME=$(uname -n) PS1=$'\e]0;$HOSTNAME:${PWD/#"$HOME"/\\~}\a\e[32m$HOSTNAME\e[m:\e[35m${PWD/#"$HOME"/\\~}\e[m$ '
Would do something similar to your zsh code: displays simple commands that are being executed in the title just before they're executed (for pipe lines, it only prints the simple commands in the right-most component), and when returning to the prompt hostname:current-directory (with $HOME replaced with ~).
Relevant sections of the the man page:
.sh.command
When processing a DEBUG trap, this variable contains the current command line that is about to run. The value is in the same format as the output generated by the xtrace option (minus the preceding PS4 prompt).
functrace
Causes the -x option's state and the DEBUG trap action to be inherited by functions defined using the function keyword (see Functions above) instead of being reset to default. Changes made to them within the function do not propagate back to the parent scope. Similarly, this option also causes the DEBUG trap action to be inherited by subshells.
${.sh.command} being ksh93's equivalent to zsh's $ZSH_DEBUG_CMD.
The functrace option was added in 2022, so only available in 93u+m/1.0.0 2022-08-01, latest as of writing being 93u+m/1.0.10 2024-08-01.
ksh93u+m is the community effort that maintains ksh93 based on the code from ksh93u+ 2012-08-01, the last stable release by AT&T Software Technology, led by Martijn Dekker (the m in ksh93u+m). A separate effort to maintain ksh93 based on the last beta release from AST and which led to the short-lived ksh2020 has been abandoned.
Note DEBUG trap (also supported by zsh) and zsh's preexec work at different stages of shell execution.
The preexec hook is invoked when a user presses Enter to submit shell code at the prompt of an interactive shell for evaluation (whether that shell code contains one simple command or several or compound commands such as loop), while the DEBUG trap is invoked for each "command" (not all types of command) being run.