How to make a dot repeat with lua function?

You need to properly escape the plug mapping.
This should do it:

vim.fn['repeat#set'](vim.api.nvim_replace_termcodes('<Plug>MyWonderfulMap', true, false, true), vim.v.count)