The (last-)will message is a part of the client connect api parameter set and has to be set on the connect call to the mqtt brocker. It makes no sense to implement it in a command line tool like mosquitto_pub which opens, publish a message and closes the connection. (last-)will makes only sense with a client application with a standing TCP/IP connection for detecting the connection interruption by another mqtt client.