You totally can. Just call the function so the expression in the string.format parameter list evaluates to whatever the function returns. If you want to call a function literal, it must be anonymous and be wrapped in parentheses.
E.g. this doesn’t work
function()
return "hi"
end()
But this does
(function()
return "hi"
end)()
If you don’t call the function, Lua’s tostring does its best and gives you something like function: 0x13128b0