"can optionally be" and "can be optionally"
Cambridge Dictionary explains adverb positioning.
We can put adverbs and adverb phrases at the front, in the middle or at the end of a clause.
Where there is more than one verb, mid position means after the first auxiliary verb or after a modal verb:
The government has occasionally been forced to change its mind. (after the first auxiliary verb)
You can definitely never predict what will happen. (after a modal verb)
We mightn’t ever have met. (after the modal verb and before the auxiliary verb [emphasis added])
The 3rd example is similar to OP's question, which involves a modal verb-auxiliary verb combination.
"can optionally be" is hence my suggestion.
Edit after comments from @MarcinManhattan
If be is a main verb, the adverb follows the modal verb but precedes the main verb, as described in the 2nd example above.
Cambridge Dictionary gives another example, now involving the use of be as a main verb.
be verb (EXIST) [ I ] to exist or live: formal Such terrible suffering should never be [emphasis added].
I cannot think of an example with this meaning, exist, in a phrase can optionally be.