Do you have a link to an example of DBT doing something similar?
DBT has two mechanisms to implement the blog post. The first is macros which closely resembles m4. The second is "ephemeral" models which are separate SQL files which get compiled into a CTE when referenced in the main model.