1.- while (<>) reads one line at a time and your regex tries to work over multiple lines.
2.- '^' marks the beginning of the line and it is zero-width, put it out of the parentheses.
3.- There is no need of the 'g' switch. Your regex only will match at most once.
4.- No need of 'i' switch. You are not using any alphabetic character.
One solution:
$ cat script.pl
use warnings;
use strict;
local $/;
my $file = <>;
$file =~ s/^(.*)\n^(~+)/## $1/m;
print $file;
$ cat infile
The Vedanta Philosophy
~~~~~~~~~~~~~~~
Body text
$ perl script.pl infile
## The Vedanta Philosophy
Body text