You can do it as long as you have at least one energy in the discard pile.
Any effects that search for cards have to be fulfilled as much as possible, as long as they can be fulfilled. In this case, you have to attach energies from your discard pile if you discard Milotic. You then need to attach energy from your discard pile to a Pokemon until you have attached 3. If you can only attach 2, then you stop there.